summaryrefslogtreecommitdiff
path: root/epan/tvbuff.c
AgeCommit message (Collapse)AuthorFilesLines
2013-11-06Fix buildbot, typo: Jakub Zawadzki1-1/+1
tvbuff.c:1258: warning: passing argument 2 of '__builtin___memcpy_chk' makes pointer from integer without a cast tvbuff.c:1258: warning: passing argument 2 of '__inline_memcpy_chk' makes pointer from integer without a cast svn path=/trunk/; revision=53117
2013-11-06tvb: optimize tvb_get_*guid()Jakub Zawadzki1-10/+12
we already have valid ptr from ensure_contiguous() so use it to fill structure. svn path=/trunk/; revision=53113
2013-11-06tvbuff: use always ops->tvb_sizeJakub Zawadzki1-2/+2
svn path=/trunk/; revision=53112
2013-11-06tvbuff: cleanup, remove dead code.Jakub Zawadzki1-26/+4
ensure_contiguous() will throw exception but won't return NULL. svn path=/trunk/; revision=53111
2013-10-22Optimize tvb_ensure_bytes_exist through manual inlining and removal of redundantEvan Huus1-2/+51
checks and computations. Should contain no behavioural changes at *all*, I hope. svn path=/trunk/; revision=52768
2013-10-22Revert 52695.Anders Broman1-94/+30
svn path=/trunk/; revision=52763
2013-10-19Minor optimizations.Anders Broman1-30/+94
svn path=/trunk/; revision=52695
2013-10-17Revert the optimization in r52578. As Jakub predicted, it caused at least oneEvan Huus1-15/+0
infinite loop to pop up. We're just going to have to eat the performance hit. (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9282) svn path=/trunk/; revision=52660
2013-10-17Temporarily revert r52651 it caused a regression when trying to tvb_memcpy fromEvan Huus1-22/+15
a negative offset (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9277) svn path=/trunk/; revision=52658
2013-10-16Create an internal _tvb_memcpy() without the sanity checks to be caled from ↵Anders Broman1-15/+22
tvb internal routines with sanity checks to avoid duplicated checks. svn path=/trunk/; revision=52651
2013-10-14Replace XXX with explanation based on discussion with Jakub on -dev.Evan Huus1-2/+3
svn path=/trunk/; revision=52606
2013-10-13So a while back Jeff added some code to check that the offset+length passed toEvan Huus1-0/+17
proto_tree_add_item was valid *before* we short-circuited based on a NULL tree. This was good in that it removed a common source of really-long-loop bugs. It was less good in that it cost us about 8% in speed when doing a tree-less dissection, but we decided the tradeoff was worth it. After Anders' recent mail to -dev about performance, I started thinking about how to optimize this. It occurred to me that the vast majority of the logic involved in the check was dealing with the length value - fetching the actual length if it was a counted string, calculating the length if it was -1, adding the length to the offset in a way that was free from overflows, etc. All of this is (theoretically) unnecessary - simply checking the offset without worrying about the length will still catch the very-long-loops, since it is the offset that increases in each iteration, not the length. All that to justify: - implement tvb_ensure_offset_exists which throws an exception if the offset is not within the tvb - use it instead of all the complicated other logic in the pre-short-circuit step of proto_tree_add_item and friends This gives us back about 3/4 of the performance we lost in the original patch. We're still ~2% slower than without any check, but this is the best I can think of right now. svn path=/trunk/; revision=52578
2013-10-13Order our conditionals to take advantage of the fact that we know tvb->length <=Evan Huus1-22/+14
tvb->reported_length. Small performance win on the hot path, and a bit easier to read. svn path=/trunk/; revision=52577
2013-10-12Tweak/simplify some tvbuff length check functions slightly. In my benchmarks ofEvan Huus1-24/+12
dissecting without tree, they are costly because they now happen for every proto_tree_add_item call even if tree is NULL. svn path=/trunk/; revision=52575
2013-10-12If the offset is out of bounds, have tvb_length_remaining() and ↵Chris Maynard1-3/+3
tvb_reported_length_remaining() return 0 instead of -1. This should provide a better long-term fix for bugs/problems such as seen in https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9263. In the long-run, if we like this behavior, we can change the return value to a guint as well. Let's let it simmer for awhile first ... svn path=/trunk/; revision=52571
2013-09-22More emem -> wmem conversion:Pascal Quantin1-105/+46
- tvb_get_g_stringz()/tvb_get_ephemeral_stringz()/tvb_get_seasonal_stringz() -> tvb_get_stringz() - tvb_get_g_stringz_enc()/tvb_get_ephemeral_stringz_enc() -> tvb_get_stringz_enc() - tvb_get_ephemeral_unicode_stringz() -> tvb_get_unicode_stringz() - tvb_bcd_dig_to_ep_str() -> tvb_bcd_dig_to_wmem_packet_str() - update docs accordingly svn path=/trunk/; revision=52180
2013-09-22emem -> wmem conversion:Pascal Quantin1-177/+48
- 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-21Add _g_ to the names of functions that allocate glib memory. This is a bit moreEvan Huus1-7/+7
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-07- no need for a doubly-linked list of TVBs, single is simplerEvan Huus1-10/+22
- support merging chains in tvb_add_to_chain - when we have an old reassembled TVB, just merge the chains rather than freeing it (we may still need it as it may already be a data source) - modelines Fixes https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9027 #BACKPORT, but it's gonna be messy... svn path=/trunk/; revision=51825
2013-08-20Fix for bug #9034: Composite TVBs aren't supported by tvb_find_guint8()Jakub Zawadzki1-6/+31
Add generic tvb_find_guint8, tvb_pbrk_guint8 svn path=/trunk/; revision=51445
2013-08-11Split some asserts so it is more clear what the problem is when they areEvan Huus1-2/+4
triggered. svn path=/trunk/; revision=51293
2013-08-04Cleanup tvbJakub Zawadzki1-7/+2
- 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-01Move a bunch of the crypt modules and pint.h into wsutil.Jeff Morriss1-4/+4
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-01tvb: check_offset_length() can calculate remaining length, use it.Jakub Zawadzki1-11/+7
svn path=/trunk/; revision=51081
2013-07-31Move composite tvbuff to seperate file (with some subtle changes).Jakub Zawadzki1-257/+0
svn path=/trunk/; revision=51071
2013-07-23Move tvb_new_child_real_data() to tvbuff_real.c with some cleanupJakub Zawadzki1-11/+0
svn path=/trunk/; revision=50843
2013-07-15Fix bug #8936: Fuzz failure: attempt to allocate -1 bytes from ↵Jakub Zawadzki1-4/+33
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-14Rewrite reassemble API to use TVBs instead of raw data.Jakub Zawadzki1-0/+9
(it seems to be working for TCP ^^) svn path=/trunk/; revision=50580
2013-07-14Move tvb real and subset implementations to seperate files.Jakub Zawadzki1-252/+11
svn path=/trunk/; revision=50569
2013-07-13Add support for cloning TVBs, move tvb_new() prototype to wtap-int.hJakub Zawadzki1-0/+42
svn path=/trunk/; revision=50558
2013-07-13Add new function: validate_offset() which checks if offset is within bounds ↵Jakub Zawadzki1-50/+31
of tvb. svn path=/trunk/; revision=50556
2013-07-13Remove compute_offset_length() Jakub Zawadzki1-46/+55
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-13Call check_offset_length_no_exception() in tvb_bytes_exist(), fix possible ↵Jakub Zawadzki1-7/+2
integer overflow svn path=/trunk/; revision=50550
2013-07-13TVB: rewrite compute_offset_length(), check_offset_length_no_exception() to ↵Jakub Zawadzki1-100/+89
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-12fix subset tvb: we want to do operation on backing tvb on position: ↵Jakub Zawadzki1-4/+4
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-11Restore old composite_memcpy() prototype. Remove it from ops.Jakub Zawadzki1-3/+3
svn path=/trunk/; revision=50498
2013-07-11packet dissection now takes pointer to tvb instead of guint8 dataJakub Zawadzki1-1/+1
implement frame_tvbuff, right now almost a copy of 'real' tvb. svn path=/trunk/; revision=50497
2013-07-11tvbuff: try to fix compilation problems for C++-like compilers.Jakub Zawadzki1-14/+19
svn path=/trunk/; revision=50496
2013-07-10tvbuff: remove ->tvb_init() from opsJakub Zawadzki1-42/+15
->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-10tvbuff: allow tvb-implementations using their own structure (it's fine as ↵Jakub Zawadzki1-29/+73
long as first member of struct is tvbuff) Move some stuff outside tvbuff struct. svn path=/trunk/; revision=50489
2013-07-10Fix previous commit. Devel env with -w in CFLAGS is not so good idea...Jakub Zawadzki1-6/+6
svn path=/trunk/; revision=50487
2013-07-10tvbuff: replace type with operation vtableJakub Zawadzki1-132/+167
It's begin of work to allow adding new tvbuff types (think: wtap_tvbuff, base64_tvbuff). svn path=/trunk/; revision=50486
2013-07-09tvbuff: use ep_strbuf_append_unichar()Jakub Zawadzki1-26/+6
svn path=/trunk/; revision=50477
2013-07-09tvb subset: move setting tvb->ds_tvb to tvb_new_with_subset()Jakub Zawadzki1-18/+6
svn path=/trunk/; revision=50464
2013-07-01Get rid of variable, 'end'.Chris Maynard1-3/+1
svn path=/trunk/; revision=50285
2013-07-01There are a few dissectors that pass the return value of ↵Chris Maynard1-9/+12
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-05-17As suggested by Jakub: don't ep_alloc buffers for TVBs, use g_malloc()'dJeff Morriss1-1/+9
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-04-21When creating a subset tvbuff, inherit the flags from the tvbuff ofGuy Harris1-0/+1
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-20When we're dissecting the beginning of a fragmented packet that weGuy Harris1-105/+57
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-19Pull tvb_init() into tvb_new(); there's no other way to get a newGuy Harris1-12/+5
tvbuff, so we might as well keep all the "here's a new tvbuff" code together. svn path=/trunk/; revision=48939