Commit Graph

258 Commits

Author SHA1 Message Date
Jakub Zawadzki c27481b03c Fix for bug #9034: Composite TVBs aren't supported by tvb_find_guint8()
Add generic tvb_find_guint8, tvb_pbrk_guint8

svn path=/trunk/; revision=51445
2013-08-20 19:56:57 +00:00
Evan Huus 9fdf6f28e4 Split some asserts so it is more clear what the problem is when they are
triggered.

svn path=/trunk/; revision=51293
2013-08-11 13:44:11 +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
Jeff Morriss 2df54da6e2 Move a bunch of the crypt modules and pint.h into wsutil.
This means wsutil now links against libcrypt.

Protect a bunch of the crypt header files from multiple inclusion.

svn path=/trunk/; revision=51100
2013-08-01 23:34:47 +00:00
Jakub Zawadzki 10e40c1638 tvb: check_offset_length() can calculate remaining length, use it.
svn path=/trunk/; revision=51081
2013-08-01 16:54:22 +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
Jakub Zawadzki 761b763eae Move tvb_new_child_real_data() to tvbuff_real.c with some cleanup
svn path=/trunk/; revision=50843
2013-07-23 17:23:51 +00:00
Jakub Zawadzki fec836d697 Fix bug #8936: Fuzz failure: attempt to allocate -1 bytes from packet-bacapp.c and/or tvb_generic_clone_offset_len()
Revert r50556: Add new function: validate_offset() which checks if offset is within bounds of tvb.

svn path=/trunk/; revision=50633
2013-07-15 18:32:11 +00:00
Jakub Zawadzki c766e78cfa Rewrite reassemble API to use TVBs instead of raw data.
(it seems to be working for TCP ^^)

svn path=/trunk/; revision=50580
2013-07-14 14:42:05 +00:00
Jakub Zawadzki 0d85b75305 Move tvb real and subset implementations to seperate files.
svn path=/trunk/; revision=50569
2013-07-14 07:42:19 +00:00
Jakub Zawadzki ef93945811 Add support for cloning TVBs, move tvb_new() prototype to wtap-int.h
svn path=/trunk/; revision=50558
2013-07-13 17:53:33 +00:00
Jakub Zawadzki af61f188e0 Add new function: validate_offset() which checks if offset is within bounds of tvb.
svn path=/trunk/; revision=50556
2013-07-13 14:51:25 +00:00
Jakub Zawadzki d5450ff925 Remove compute_offset_length()
We either want to calculate only offset (compute_offset()), or
offset and remaining length (compute_offset_and_remaining())

Move old generic code to check_offset_length_no_exception())

svn path=/trunk/; revision=50551
2013-07-13 10:28:19 +00:00
Jakub Zawadzki 614e45a25a Call check_offset_length_no_exception() in tvb_bytes_exist(), fix possible integer overflow
svn path=/trunk/; revision=50550
2013-07-13 09:48:55 +00:00
Jakub Zawadzki cae2ce3b05 TVB: rewrite compute_offset_length(), check_offset_length_no_exception() to return exception number instead of FALSE, and 0 instead of TRUE
+ if there's overflow in check_offset_length_no_exception() just set exception, don't clamp end_offset (it could be an issue for 4GB tvbs :>)


svn path=/trunk/; revision=50549
2013-07-13 09:17:32 +00:00
Jakub Zawadzki d2b93398f9 fix subset tvb: we want to do operation on backing tvb on position: abs_offset + subset_offset, abs_offset - subset_offset makes no sense.
Right now it doesn't really matter, cause tvb subsets always have real_data.

Without fix, and with small modification in ensure_contigous_no_expcetion() to first check for ->tvb_get_ptr() and later real_data
epan doesn't work and it flood console with warnings like:
** (process): WARNING **: Dissector bug, protocol IPv4, in packet 3823: tvbuff.c:976: failed assertion "exception > 0"


svn path=/trunk/; revision=50537
2013-07-12 17:53:51 +00:00
Jakub Zawadzki 356a4613c7 Restore old composite_memcpy() prototype. Remove it from ops.
svn path=/trunk/; revision=50498
2013-07-11 05:51:19 +00:00
Jakub Zawadzki ce81449ed9 packet dissection now takes pointer to tvb instead of guint8 data
implement frame_tvbuff, right now almost a copy of 'real' tvb.

svn path=/trunk/; revision=50497
2013-07-11 05:47:02 +00:00
Jakub Zawadzki 19d2d0dc76 tvbuff: try to fix compilation problems for C++-like compilers.
svn path=/trunk/; revision=50496
2013-07-11 04:35:12 +00:00
Jakub Zawadzki 338f1c9654 tvbuff: remove ->tvb_init() from ops
->tvb_init() knows nothing about new tvb and can only do some kind of bzero()
it's much better if we initialize object after tvb_new() [which anyway must be done]

+ try to fix OSX build.

svn path=/trunk/; revision=50490
2013-07-10 19:25:49 +00:00
Jakub Zawadzki d7175365ab tvbuff: allow tvb-implementations using their own structure (it's fine as long as first member of struct is tvbuff)
Move some stuff outside tvbuff struct.

svn path=/trunk/; revision=50489
2013-07-10 19:08:02 +00:00
Jakub Zawadzki b4d8a3727f Fix previous commit. Devel env with -w in CFLAGS is not so good idea...
svn path=/trunk/; revision=50487
2013-07-10 18:25:24 +00:00
Jakub Zawadzki f3ed13c22e tvbuff: replace type with operation vtable
It's begin of work to allow adding new tvbuff types (think: wtap_tvbuff, base64_tvbuff).

svn path=/trunk/; revision=50486
2013-07-10 18:14:15 +00:00
Jakub Zawadzki 83322789d1 tvbuff: use ep_strbuf_append_unichar()
svn path=/trunk/; revision=50477
2013-07-09 23:10:04 +00:00
Jakub Zawadzki 398f94dd24 tvb subset: move setting tvb->ds_tvb to tvb_new_with_subset()
svn path=/trunk/; revision=50464
2013-07-09 16:22:53 +00:00
Chris Maynard 9a394ddfa0 Get rid of variable, 'end'.
svn path=/trunk/; revision=50285
2013-07-01 06:03:35 +00:00
Chris Maynard 8976968f4c There are a few dissectors that pass the return value of tvb_length_remaining() as the size argument to the tvb_format_*() functions. Try to do something sane if that value happens to be -1 (or negative in general). One such example is packet-bthfp.c, as found and reported by Coverity in CID 1035325 (Improper use of negative value).
Note: There are other ways to handle this of course, but this fix is suitable for backporting to both 1.10 and 1.8, as it does not break binary compatibility.  Is there a better way to fix this though?  For now, schedule this for backport.

svn path=/trunk/; revision=50282
2013-07-01 05:23:17 +00:00
Jeff Morriss 86744b65da As suggested by Jakub: don't ep_alloc buffers for TVBs, use g_malloc()'d
memory with tvb-free-callback.

Fixes one of the "read after free" warnings from Valgrind reported in
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8197 and the one reported
in https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8653

svn path=/trunk/; revision=49379
2013-05-17 14:38:36 +00:00
Guy Harris 09e0d5b406 When creating a subset tvbuff, inherit the flags from the tvbuff of
which we're making a subset, so that if the parent tvbuff is marked as a
fragment, the child tvbuff will be marked as one as well.

svn path=/trunk/; revision=48953
2013-04-21 17:38:57 +00:00
Guy Harris 0efcd0632b When we're dissecting the beginning of a fragmented packet that we
haven't reassembled, we're probably moving sequentially through the
packet, which means that we'll run past the end of the fragment rather
than past the end of what would have been the reassembled packet had we
reassembled it.

I.e., there's little reason to care whether we're past the end of the
fragment but not past the end of the packet, or whether we're past the
end of the packet; in either case, we're past the end of the fragment,
and if somebody wants to know whether the packet is malformed by
stopping short of certain fields, they should enable reassembly.

So we get rid of the explicit fragment length in tvbuffs and, instead,
have a "this is a fragment" flag; if that flag is set, we throw
FragmentBoundsError rather than ReportedBoundsError if we run past the
end of the reported data.

(This also means we could flag the tvbuff even if we don't know how
large the reassembled packet will be, e.g. when doing IP reassembly.)

Replace tvb_new_subset_length_fragment() with tvb_new_subset_length()
and a new "set the "this is a fragment flag"" routine.

svn path=/trunk/; revision=48940
2013-04-20 02:53:57 +00:00
Guy Harris 5524d0f801 Pull tvb_init() into tvb_new(); there's no other way to get a new
tvbuff, so we might as well keep all the "here's a new tvbuff" code
together.

svn path=/trunk/; revision=48939
2013-04-19 23:39:35 +00:00
Guy Harris 36dfc6b108 Clean up a bit.
svn path=/trunk/; revision=48937
2013-04-19 18:48:16 +00:00
Guy Harris c0c15029ed Add to tvbuffs a "fragment length" field; if the tvbuff represents the
first fragment of a non-reassembled packet, and we know the length the
packet would have if it were reassembled, this field holds the length of
the fragment, and the "reported length" field shows the length the
packet would have if it were reassembled, so going past the end of the
fragment but staying within the length of the reassembled packet can be
reported as "dissection would have worked if the packet had been
reassembled" rather than "the packet is too short, so it was probably
malformed".

Add a FragmentBoundsError exception, thrown in the "dissection would
have worked if the packet had been reassembled" case.

Add a new tvb_new_subset_length_fragment() routine to create a new
subset tvb with specified fragment and reported lengths.  Use it in the
CLNP dissector.

Add some more sanity checks in the CLNP dissector.

svn path=/trunk/; revision=48917
2013-04-18 19:22:24 +00:00
Pascal Quantin 95938370bd From Ed Beroset via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8416 :
Remove C++ incompatibilities from tvbparse and tvbuff

svn path=/trunk/; revision=48025
2013-03-02 23:05:27 +00:00
Bill Meier 96a24cc79f Fix spelling/typos found using a list of commonly misspelled words.
The misspellings were mostly in comments but some were
in text strings visible to the user.


svn path=/trunk/; revision=47899
2013-02-26 04:42:26 +00:00
Guy Harris d02eea90a2 compute_offset_length(), check_offset_length_no_exception(), and
check_offset_length() are always passed the captured length and reported
length of a tvbuff; just pass a pointer to the tvbuff, instead.

Eliminate some extra blank lines.

svn path=/trunk/; revision=47868
2013-02-24 21:45:09 +00:00
Guy Harris 14b01f991c tvb_set_subset_no_exceptions() is called immediately after all calls to
tvb_new_with_subset(), and is not called anywhere other than immediately
after calls to tvb_new_with_subset(); absorb it into tvb_new_with_subset().

svn path=/trunk/; revision=47867
2013-02-24 21:30:00 +00:00
Guy Harris 370eae07ad Move some routines around, in preparation for some other code
reorganization.

svn path=/trunk/; revision=47866
2013-02-24 21:18:45 +00:00
Guy Harris 6c575002e5 Fix copy-and-pasteo.
svn path=/trunk/; revision=47769
2013-02-20 08:37:40 +00:00
Guy Harris 67e692da1c Add a tvb_new_subset_length() that takes a tvbuff, an offset in a
tvbuff, and a length from that offset, and returns a subset tvbuff
referring to that data (or throws an exception).  This does what most if
not all calls to tvb_new_subset() (other than the ones that really
should be calls to tvb_new_subset_remaining()) should be doing, i.e.
setting the reported length of the tvbuff to the specified length and
calculating the appropriate value of the captured length based on that.

We aren't using it yet, but we will....

svn path=/trunk/; revision=47768
2013-02-20 08:10:14 +00:00
Guy Harris cf1070b4b1 Swallow up tvb_set_real_data_no_exceptions() into tvb_new_real_data() -
the only caller is tvb_new_real_data().

svn path=/trunk/; revision=47757
2013-02-20 01:01:32 +00:00
Guy Harris 75168f6bf7 No more tvb_new(), so no more need for tvb_set_real_data() or
tvb_set_subset(); code should use tvb_new_real_data() and various
tvb_new_subset routines.  (Neither tvb_new() nor tvb_set_real_data() nor
tvb_set_subset() were exported in libwireshark.def, nor were they used
outside tvbuff.c; tvb_set_real_data() and tvb_set_subset() weren't even
being used *inside* tvbuff.c.)

svn path=/trunk/; revision=47753
2013-02-20 00:09:41 +00:00
Guy Harris bd7c0171a9 Make tvb_new() an internal routine to epan/tvbuff.c; we export various
routines to create new tvbuffs that do what dissectors need to do, and
those are the only routines that should be used.

svn path=/trunk/; revision=47752
2013-02-19 23:55:19 +00:00
Martin Kaiser 50945da41c check the length parameter for tvb_get_unicode_string() and
tvb_get_ephemeral_unicode_string(), throw an exception for invalid
lengths (including -1, but length==-1 does not work for other tvb string
functions either)

I believe this is the proper fix for
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8112

svn path=/trunk/; revision=46705
2012-12-22 22:35:07 +00:00
Jeff Morriss bd3a06065d Another composite-TVB fix inspired by
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8097 :

Assert out if tvb_composite_finalize() is called on a composite TVB with
no members (sub-TVBs).

svn path=/trunk/; revision=46570
2012-12-16 19:26:12 +00:00
Jeff Morriss 306821bf6e As suggested by Evan in https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8097 :
Put r46564 back in as the computation of member_length is non-trivial.

svn path=/trunk/; revision=46567
2012-12-16 18:23:10 +00:00
Jeff Morriss c6c5c3d978 A different fix for https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8097 :
Rather than asserting out when we find a zero-length TVB in a composite TVB,
assert out when a dissector adds a zero-length TVB to a composite.

svn path=/trunk/; revision=46566
2012-12-16 16:49:52 +00:00
Evan Huus 18538f6c8a DISSECTOR_ASSERT on member_length when composing a disjoint tvb in order to
avoid an infinite recursion. More robust handling of the error case in
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8097
but doesn't fix the actual bug (which is that either DHCP or BOOTP is building
an invalid tvbuff).

svn path=/trunk/; revision=46564
2012-12-16 16:21:41 +00:00
Jeff Morriss 3729335973 We always HAVE_CONFIG_H so don't bother checking whether we have it or not.
svn path=/trunk/; revision=45016
2012-09-20 01:48:30 +00:00
Jakub Zawadzki bf81b42e1e Update Free Software Foundation address.
(COPYING will be updated in next commit)

svn path=/trunk/; revision=43536
2012-06-28 22:56:06 +00:00