aboutsummaryrefslogtreecommitdiffstats
path: root/epan/tvbuff.c
AgeCommit message (Collapse)AuthorFilesLines
2011-04-04From jakub Zawadzki:etxrab1-0/+2
I've fixed composite tests #0 and #2 git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@36440 f5534014-38df-0310-8fa8-9805f1628bb7
2011-01-30Fix various instances of "unreachable code".wmeier1-2/+0
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@35713 f5534014-38df-0310-8fa8-9805f1628bb7
2011-01-28Mention that the fake tvb unicode functions have been supercededsfisher1-0/+1
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@35689 f5534014-38df-0310-8fa8-9805f1628bb7
2011-01-20Fix the dead initialization warnings found by clang's static analysissfisher1-1/+1
("Value stored to 'xxx' during its initialization is never read") git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@35598 f5534014-38df-0310-8fa8-9805f1628bb7
2011-01-14Add tvb_get_[n|le]toh[40|48|56]() accessors. Addresses bug 5082.cmaynard1-0/+54
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@35538 f5534014-38df-0310-8fa8-9805f1628bb7
2011-01-12There's no need to call tvb_get_ptr() in here: just call ensure_contiguous() ↵morriss1-5/+5
directly. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@35509 f5534014-38df-0310-8fa8-9805f1628bb7
2011-01-12Introduce, and start using, tvb_get_const_stringz(). This function returns amorriss1-9/+34
pointer to a NULL-terminated string in the TVB. It is no safer than dissectors which call tvb_get_strsize() and then tvb_get_ptr() but it makes it clear that this usage of tvb_get_ptr() is safe. This function is slightly more efficient than tvb_get_ephemeral_stringz()--but only as long as we're not using composite TVBs. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@35493 f5534014-38df-0310-8fa8-9805f1628bb7
2011-01-03Introduce two new functions for Unicode (UTF-16) string handling:sfisher1-1/+98
tvb_get_unicode_string() tvb_get_ephemeral_unicode_string() These function like their counterparts, tvb_get_string and tvb_get_epemeral_string, for standard strings. Also update comment on what the first such function, tvb_get_ephemeral_unicode_stringz does regarding updating lengthp. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@35344 f5534014-38df-0310-8fa8-9805f1628bb7
2010-12-28Add tvb_bcd_dig_to_ep_str()etxrab1-0/+65
/* * Given a tvbuff, an offset into the tvbuff, and a length that starts * at that offset (which may be -1 for "all the way to the end of the * tvbuff"), fetch BCD encoded digits from a tvbuff starting from either * the low or high half byte, formating the digits according to an input digit set, * if NUll a default digit set of 0-9 returning "?" for overdecadic digits will be used. * A pointer to the EP allocated string will be returned. * Note a tvbuff content of 0xf is considered a 'filler' and will end the conversion. */ git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@35286 f5534014-38df-0310-8fa8-9805f1628bb7
2010-12-23Add a couple more comments to new unicode function to remind us when asfisher1-2/+2
variable is counting UTF-16 characters vs. normal bytes. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@35256 f5534014-38df-0310-8fa8-9805f1628bb7
2010-12-23Remove comment to myself that I forgot to remove before commiting r35253sfisher1-4/+7
and change comments to fit within 80 column display. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@35255 f5534014-38df-0310-8fa8-9805f1628bb7
2010-12-23Introduce new function called tvb_get_ephemeral_unicode_stringz(), whichsfisher1-0/+68
is a unicode (UTF-16) version of tvb_get_ephemeral_stringz(). It scans a tvbuff for a UTF-16 string and converts it to UTF-8 upon return. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@35253 f5534014-38df-0310-8fa8-9805f1628bb7
2010-11-23From Vincent Helfre:etxrab1-1/+1
Bug in tvb_get_bits32(), The last bitshift is too large, which causes the least significant bits to be 0 all the time. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@35015 f5534014-38df-0310-8fa8-9805f1628bb7
2010-10-30Make tvb_strncaseeql()'s size parameter be a size_t. Cast the size to int ↵morriss1-3/+3
before calling ensure_contiguous_no_exception() (also in tvb_strneql()). git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@34727 f5534014-38df-0310-8fa8-9805f1628bb7
2010-10-30Make tvb_strneql()'s size parameter be a size_t. Remove some ↵morriss1-3/+3
now-unnecessary casts. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@34725 f5534014-38df-0310-8fa8-9805f1628bb7
2010-08-16Clean up indentation.guy1-24/+25
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@33814 f5534014-38df-0310-8fa8-9805f1628bb7
2010-08-16From rodebiet:etxrab1-16/+24
tvb_get_bits32 produces malformed_packet if no_of_bits < 25 and tvb remaining = 3 https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5080 git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@33811 f5534014-38df-0310-8fa8-9805f1628bb7
2010-05-24Refer to the endianness arguments as "encoding" rather thanguy1-2/+8
"representation" - we already use "representation" to refer to the text representation of fields. Change some routines with an endianness argument to make it a representation argument instead; git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@32929 f5534014-38df-0310-8fa8-9805f1628bb7
2010-04-28From Jakub Zawadzki:etxrab1-16/+1
- use Glibc:s highly optimized memchr() git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@32584 f5534014-38df-0310-8fa8-9805f1628bb7
2010-04-28From Jakub Zawadzki:etxrab1-15/+13
- optimize guint8_pbrk(). git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@32583 f5534014-38df-0310-8fa8-9805f1628bb7
2010-04-03 From Yaniv Kaul: constify parameterswmeier1-100/+100
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4422 From me: Fix a number of instances where the function prototype or the function definition wasn't changed so there was a mismatch thus causing Windows (but not gcc) compilation errors. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@32365 f5534014-38df-0310-8fa8-9805f1628bb7
2010-04-02Revert SVN #32360 until Windows compilation errors corrected.wmeier1-100/+100
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@32361 f5534014-38df-0310-8fa8-9805f1628bb7
2010-04-02From Yaniv Kaul: constify parameterswmeier1-100/+100
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4422 git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@32360 f5534014-38df-0310-8fa8-9805f1628bb7
2010-03-09Mark unused arguments.guy1-11/+14
Clean up white space. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@32149 f5534014-38df-0310-8fa8-9805f1628bb7
2010-01-28Fix various gcc -Wshadow warnings.wmeier1-16/+16
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@31720 f5534014-38df-0310-8fa8-9805f1628bb7
2010-01-25parent is not unused in tvb_child_uncompress().stig1-1/+1
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@31658 f5534014-38df-0310-8fa8-9805f1628bb7
2009-11-23Make more output parameters optional.jake1-8/+16
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@31059 f5534014-38df-0310-8fa8-9805f1628bb7
2009-11-14From yy:dimeg1-0/+22
About GSM system information type 2quater Modified to use newly defined tvb_get_bits() in tvbuff.c https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4219 git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@30962 f5534014-38df-0310-8fa8-9805f1628bb7
2009-11-04tvb_format_text() always returns a non NULL pointer so don't check return ↵krj1-5/+2
value for NULL pointer git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@30821 f5534014-38df-0310-8fa8-9805f1628bb7
2009-10-08Add DISSECTOR_ASSERT() before dereferencing a possible NULL pointerkrj1-0/+2
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@30404 f5534014-38df-0310-8fa8-9805f1628bb7
2009-10-04Use g_new0() when allocating z_streamkrj1-1/+1
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@30277 f5534014-38df-0310-8fa8-9805f1628bb7
2009-10-04Use GLibs CLAMP(). The current inlined implementation seems to be wrong:krj1-8/+1
} else if (bufsiz > TVB_Z_MAX_BUFSIZ) { bufsiz = TVB_Z_MIN_BUFSIZ; } This should probably have been 'bufsiz = TVB_Z_MAX_BUFSIZ;' git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@30276 f5534014-38df-0310-8fa8-9805f1628bb7
2009-10-04Delay allocation of z_streamkrj1-6/+2
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@30275 f5534014-38df-0310-8fa8-9805f1628bb7
2009-10-04g_malloc0() doesn't return NULL so remove NULL error pathskrj1-27/+1
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@30274 f5534014-38df-0310-8fa8-9805f1628bb7
2009-09-20Remove 'type' formal parameter from tvb_new_with_subset()krj1-83/+83
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@29988 f5534014-38df-0310-8fa8-9805f1628bb7
2009-09-10offset_from_real_beginning() is only called with 0 as second argument, so ↵krj1-4/+10
remove the argument completely. It seems that the second argument only acts as an accumulator allowing offset_from_real_beginning() to call itself recursively. To be consistent offset_from_real_beginning() is renamed to tvb_offset_from_real_beginning(). git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@29844 f5534014-38df-0310-8fa8-9805f1628bb7
2009-08-16Add a new function, tvb_new_subset_remaining(), which is a sligtly optimized ↵krj1-3/+35
version of tvb_new_subset(). The latter can be mapped to the former by tvb_new_subset(tvb, offset, -1 /* backing_length */, -1 /* reported_length */). We can disable some bounds checking because 'backing_length' and 'reported_length' are hardcoded to -1. The current implementation of tvb_new_subset_remaining() only has the THROW_ON(reported_length < 1) check removed when compared to tvb_new_subset(). So there's room for improvement in this function. We should be able to disable some more (redundant) bounds checking. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@29445 f5534014-38df-0310-8fa8-9805f1628bb7
2009-08-16Remove unused parameterskrj1-4/+3
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@29444 f5534014-38df-0310-8fa8-9805f1628bb7
2009-08-16Remove the non-thread safe usage of 'last_tvb' variable in tvb_new_subset()krj1-27/+29
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@29443 f5534014-38df-0310-8fa8-9805f1628bb7
2009-08-16Make some of the check_XXX functions accept the length/reported length of ↵krj1-35/+53
the tvbuff as arguments instead the tvbuff. We'll need this feature in order to remove the non-thread usage of the 'last_tvb' variable in tvb_new_subset() git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@29442 f5534014-38df-0310-8fa8-9805f1628bb7
2009-08-16Remove a non thread-safe usage (useful when/if we ever support threading) of ↵krj1-22/+14
a static tvbuff in tvb_new_real_data(). The current version uses a static 'last_tvb' to keep track of the last allocated tvbuff. This is needed because some of the function we call can throw an exception. This patch improves this strategy by throwing an exception (if needed) before we try to allocate the tvbuff. This way we avoid a memleak _and_ we don't have to track the 'last_tvb' tvbuff. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@29441 f5534014-38df-0310-8fa8-9805f1628bb7
2009-08-15Use the slice allocator if GLIB >= 2,10,0 as suggested by Anders Bromankrj1-0/+17
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@29434 f5534014-38df-0310-8fa8-9805f1628bb7
2009-08-15Add a missing DISSECTOR_ASSERT in tvb_init()krj1-0/+4
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@29433 f5534014-38df-0310-8fa8-9805f1628bb7
2009-08-15Make mem chunk statickrj1-4/+1
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@29432 f5534014-38df-0310-8fa8-9805f1628bb7
2009-08-11(Trivial change) move ensure_contiguous() to reflect call hierarchykrj1-16/+14
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@29382 f5534014-38df-0310-8fa8-9805f1628bb7
2009-08-11Turn a comment in fast_ensure_contiguous() into a DISSECTOR_ASSERT() to make ↵krj1-3/+4
the implied requirement explicit. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@29381 f5534014-38df-0310-8fa8-9805f1628bb7
2009-06-11Remove some "statement not reached" warnings.stig1-6/+1
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@28691 f5534014-38df-0310-8fa8-9805f1628bb7
2009-06-08Fixed check for no_of_bits in tvb_get_bits16(), tvb_get_bits32() andstig1-14/+10
tvb_get_bits64(). git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@28658 f5534014-38df-0310-8fa8-9805f1628bb7
2009-04-24Added tvb_format_stringzpad_wsp().stig1-0/+24
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@28140 f5534014-38df-0310-8fa8-9805f1628bb7
2009-04-05Reapply the change from revision 27946.guy1-1/+12
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@27963 f5534014-38df-0310-8fa8-9805f1628bb7