Commit Graph

21 Commits

Author SHA1 Message Date
Peter Wu 0b179d901e composite_tvb: fix memory leak when tvb_composite_finalize is not called
There is a window where the memory for the composite TVB can be leaked,
namely between calling tvb_composite_new and tvb_composite_finalize.
This can occur due to complex dissector logic (bug 16375) or due to
exceptions preventing tvb_composite_finalize from being called.

Fix this by attaching the composite TVB sooner to another TVB. Ideally
tvb_composite_new is changed to receive the initial TVB as parameter,
but that would change its API.

While at it, remove a redundant NULL-pointer check and comment. The
comment referring to a union was likely about avoiding the const-cast.

Bug: 16375
Change-Id: Ic8c6d1da6fbd5ff9f16b1280af3aab23f9ed470d
Reviewed-on: https://code.wireshark.org/review/37345
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-06-01 03:40:57 +00:00
Guy Harris 20800366dd HTTPS (almost) everywhere.
Change all wireshark.org URLs to use https.

Fix some broken links while we're at it.

Change-Id: I161bf8eeca43b8027605acea666032da86f5ea1c
Reviewed-on: https://code.wireshark.org/review/34089
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-07-26 18:44:40 +00:00
Peter Wu ec5adb0ce9 tvbuff_composite: fix buffer overflow due to wrong offset adjustment
The tvb_offset method should return the offset of the buffer within the
backing tvb (ds_tvb). The currently returned non-zero offset is valid
for tvbuff_subset.c, but not for the composite TVB. The backing tvb is
the tvb itself, so the offset should be zero (or "counter" for
consistency with tvbuff_real.c and others).

This bug is observable with the capture from the bug. In tshark, the
data field in the PDML output has value "field length invalid!" and the
position attribute ("pos") is too large. With the -V option it even
crashes with a buffer overflow (read). In the GUI, the bytes tab shows
range 3199-19642 even if the data source is only 16444 bytes while the
selection should have been 0-16443.

Bug: 14466
Change-Id: I01399ff500321dba262eb60b67c4cddb173b4679
Reviewed-on: https://code.wireshark.org/review/30124
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-10-12 05:07:08 +00:00
Guy Harris 0a130c5756 Handle subset tvbuffs where the length goes past the end of the parent.
Add a "contained length" to tvbuffs.  For non-subset tvbuffs, that's the
same as the reported length.  For a subset tvbuff, that's the amount of
the reported data that was actually present in the "contained data" of
the parent tvbuff.

This is unaffected by the *captured* length of any tvbuff; that differs
from the contained length only if the capture was cut short by a
snapshot length.

If a reference is within the reported data, but not within the contained
data, a ContainedBoundsError exception is thrown.  This exception
represents a protocol error, rather than a reference past the captured
data in the packet; we treat it as such.

Change-Id: Ide87f81238eaeb89b3093f54a87bf7f715485af5
Reviewed-on: https://code.wireshark.org/review/27039
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-04-20 03:18:47 +00:00
Dario Lombardo 55c68ee69c epan: use SPDX indentifiers.
Skipping dissectors dir for now.

Change-Id: I717b66bfbc7cc81b83f8c2cbc011fcad643796aa
Reviewed-on: https://code.wireshark.org/review/25694
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-08 19:29:45 +00:00
Pascal Quantin 4fd9872d11 tvbuff_composite.c: fix composite_get_ptr when length is over 2 segments
When storing a copy of the composite tvb in tvb->real_data, ensure to copy the full
data and not only the length currently requested by the call to tvb_get_ptr()

Change-Id: I6b42f3d46c4fba83fadf4d06f465c8d2486f4853
Reviewed-on: https://code.wireshark.org/review/18806
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2016-11-13 22:30:57 +00:00
Pascal Quantin 35feab8a4a Fix display of composite tvbs in GUI
a composite tvb is the top-level data source tvb
fix composite_get_ptr function

Change-Id: Ibab58801a754fd88fb86b9a13804bccf2ad51c7a
Reviewed-on: https://code.wireshark.org/review/15643
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-05-31 16:53:41 +00:00
Pascal Quantin e0eefbe20a tvbuff_composite.c: do not recompute abs_length
abs_length is already computed by the caller of composite_get_ptr (ensure_contiguous_no_exception).
No need to do the work another time

Change-Id: I93edd6d405b2d5afe99dc7c781ecea4b395ef7bd
Reviewed-on: https://code.wireshark.org/review/15053
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-04-22 21:26:37 +00:00
Pascal Quantin 9abbf8b69d Do not mix wmem and glib allocators
Change-Id: I0e845668a1b9dbec93ea920a8585ecfe60f001d1
Reviewed-on: https://code.wireshark.org/review/15044
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-04-22 04:32:32 +00:00
Evan Huus 9b5b7c1a90 Remove deprecated tvb_length calls
Trust that the files in epan/ immediately (not dissectors) know what they're
doing so just blindly convert them to captured length.

Change-Id: I872f7d58b2e15ae82c75fd56f4873996fbc97be7
Reviewed-on: https://code.wireshark.org/review/9083
Reviewed-by: Evan Huus <eapache@gmail.com>
2015-06-24 00:31:25 +00:00
Guy Harris 44e7ce54ff Remove some apparently-unnecessary includes of emem.h.
Change-Id: Ib7d1b587b439ff21ec6b7f1756ce6ccf25b66f80
Reviewed-on: https://code.wireshark.org/review/6635
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-01-18 20:19:05 +00:00
Alexis La Goutte 5ec1ab4101 tvbuff composite: add modelines infos (tabs)
Change-Id: I9ea2160b550243b45f6798ad3339f6a45b34a4ef
Reviewed-on: https://code.wireshark.org/review/3991
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-09-04 19:31:57 +00:00
Alexis La Goutte 67bff64ad7 tvbuff composite: fix Dereference of null pointer found by Clang Analyzer
Change-Id: Ia43cb2e1cab99e4b769c8dfa0805d8e38e225a1c
Reviewed-on: https://code.wireshark.org/review/3990
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-09-04 19:31:47 +00:00
Alexis La Goutte 296591399f Remove all $Id$ from top of file
(Using sed : sed -i '/^ \* \$Id\$/,+1 d')

Fix manually some typo (in export_object_dicom.c and crc16-plain.c)

Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8
Reviewed-on: https://code.wireshark.org/review/497
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-04 14:27:33 +00:00
Pascal Quantin a0c53ffaa1 emem -> wmem conversion:
- ep_tvb_get_bits() -> wmem_packet_tvb_get_bits()
- tvb_g_memdup()/ep_tvb_memdup() -> tvb_memdup()
- tvb_fake_unicode()/tvb_get_ephemeral_faked_unicode() -> tvb_get_faked_unicode()
- tvb_get_g_string()/tvb_get_ephemeral_string()/tvb_get_seasonal_string() -> tvb_get_string()
- tvb_get_g_unicode_string()/tvb_get_ephemeral_unicode_string() -> tvb_get_unicode_string()
- tvb_get_ephemeral_string_enc() -> tvb_get_string_enc()
- update docs accordingly

svn path=/trunk/; revision=52172
2013-09-22 15:50:55 +00:00
Evan Huus 6df83e8078 Add _g_ to the names of functions that allocate glib memory. This is a bit more
explicit, and frees up the "generic" names (like tvb_memdup) for new signatures
that take the appropriate wmem pool.

Majority of the conversion done with sed.

svn path=/trunk/; revision=52164
2013-09-21 17:04:41 +00:00
Jörg Mayer 029e258225 Explicitly include emem.h where it is needed
svn path=/trunk/; revision=51997
2013-09-13 08:16:50 +00:00
Jakub Zawadzki 8ade8c4750 Composite tvb (tvb_memcpy/tvb_get_ptr): don't assert with offset == tvb->length, and 0 length
svn path=/trunk/; revision=51444
2013-08-20 19:54:42 +00:00
Jakub Zawadzki b67492bbc0 Cleanup tvb
- make tvb_ops->tvb_size a gsize field, not function call
- remove not needed forward declaration / forward line

svn path=/trunk/; revision=51141
2013-08-04 22:02:42 +00:00
Jakub Zawadzki a2a20ed62a Move tvbuff composite structure to their own file.
svn path=/trunk/; revision=51072
2013-07-31 20:01:53 +00:00
Jakub Zawadzki 9d519b5659 Move composite tvbuff to seperate file (with some subtle changes).
svn path=/trunk/; revision=51071
2013-07-31 19:58:13 +00:00