summaryrefslogtreecommitdiff
path: root/epan/tvbuff.c
AgeCommit message (Collapse)AuthorFilesLines
2012-12-22check the length parameter for tvb_get_unicode_string() andMartin Kaiser1-0/+4
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-16Another composite-TVB fix inspired byJeff Morriss1-0/+6
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-16As suggested by Evan in ↵Jeff Morriss1-0/+3
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-16A different fix for https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8097 :Jeff Morriss1-27/+38
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-16DISSECTOR_ASSERT on member_length when composing a disjoint tvb in order toEvan Huus1-0/+1
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-09-20We always HAVE_CONFIG_H so don't bother checking whether we have it or not.Jeff Morriss1-3/+1
svn path=/trunk/; revision=45016
2012-06-28Update Free Software Foundation address.Jakub Zawadzki1-1/+1
(COPYING will be updated in next commit) svn path=/trunk/; revision=43536
2012-06-14Add some explation about buffer size.Jakub Zawadzki1-0/+2
svn path=/trunk/; revision=43266
2012-06-14Optimize tvb_*_unicode functions.Jakub Zawadzki1-40/+5
- Allocate tmpbuf on stack. g_unichar_to_utf8[1] requires maximum 6B + 1 byte for NUL, align it to 8B. - Use g_string_append_unichar() [1] http://developer.gnome.org/glib/2.26/glib-Unicode-Manipulation.html#g-unichar-to-utf8 svn path=/trunk/; revision=43263
2012-05-15Assign some variables that scan-build was complaining about.Gerald Combs1-1/+1
svn path=/trunk/; revision=42638
2012-05-15Make the encoding argument uniformly guint rather than gint.Guy Harris1-30/+92
Put the code that's currently common to the ENC_ASCII and ENC_UTF_8 cases in tvb_get_ephemeral_string_enc() into tvb_get_ephemeral_string(), and call tvb_get_ephemeral_string() in those cases. Skip the tvb_ensure_bytes_exist() and ensure_contiguous() calls in the ENC_UTF_16 and ENC_UCS_2 cases, as they're unnecessary there. Update the comment for tvb_get_ephemeral_string_enc(). Make tvb_get_ephemeral_stringz_enc() handle the encodings that tvb_get_ephemeral_string_enc() does. svn path=/trunk/; revision=42627
2012-05-14tvb_unicode_strsize() returns number of bytes, NOT number of UCS-2 characters.Jakub Zawadzki1-2/+2
svn path=/trunk/; revision=42622
2012-05-14Get rid of remaining Booleans-as-encoding-arguments inGuy Harris1-3/+3
proto_tree_add_item() calls. Add new "add_packet_field" method to the TreeItem class, taking a protocol field (*not* a protocol), TvbRange, and encoding value as arguments. Add the ENC_ values to init.lua. Make them all hex #defines so make-init-lua.pl can easily extract them. Export tvb_unicode_strsize() for use by Lua (and elsewhere as desired). Note that it handles UTF-16 and UTF-8, and fix the comment to note that its count of hexadectets *does* include the null terminator (that's what the code does). svn path=/trunk/; revision=42621
2012-05-11Add ENC_UTF_16 and ENC_UCS_2. Note that UTF-16 and UCS-2 are not theGuy Harris1-5/+69
same, and that the routines to get "Unicode" strings are really doing UCS-2 (and not doing anything about code values that aren't valid in UCS-2 strings). Have tvb_get_ephemeral_string_enc() separate cases for ASCII and UTF-8, even though they're *currently* treated the same. For FT_UINT_STRING, treat an encoding value of TRUE as meaning "little-endian ASCII"; pass all other encodings through to tvb_get_ephemeral_string_enc(). svn path=/trunk/; revision=42592
2012-04-20From Evan Huus: Use Add DISSECTOR_ASSERT_HINT() macro. ↵Anders Broman1-2/+2
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7142 svn path=/trunk/; revision=42148
2012-04-18Fix some: 'cast discards qualifiers from pointer target type' warningsJakub Zawadzki1-3/+2
- Add const qualifier - Remove some strange casts svn path=/trunk/; revision=42131
2012-04-12From Martin Kaiser: CID 525 is about tvb_new_octet_aligned(). datalen can be ↵Anders Broman1-0/+1
negative or 0 when ep_alloc0(datalen) is called. If this happens, it's because of a dissector not checking the bit_offset, I think a DISSECTOR_ASSERT() is ok for fixing this. https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7068 svn path=/trunk/; revision=42032
2012-04-06Clamp a value as suggested by Mike Morrin in bug 6878.Gerald Combs1-1/+1
svn path=/trunk/; revision=41968
2012-04-04Make bit_offset in _tvb_get_bits64 and related functions unsigned. ThisGerald Combs1-12/+12
removes a potential buffer overflow and should fix a bunch of Coverity errors mentioned in bug 6878. We might want to do the same for no_of_bits. svn path=/trunk/; revision=41945
2012-03-31These buffers in tvb_uncompress() can't ovelaps, so use optimized memcpy().Jakub Zawadzki1-4/+3
svn path=/trunk/; revision=41870
2012-03-31Fix for bug #6480 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6480)Jakub Zawadzki1-1/+11
Yay, first commit since r37883 (almost 9months). svn path=/trunk/; revision=41869
2012-02-28From Mike Morrin: Fix for "The previous patch had an error and was returning ↵Bill Meier1-84/+96
too many bits." https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6878 From me: Correct the indentation to match the rest of the file. svn path=/trunk/; revision=41230
2012-02-28Initialize "value" in _tvb_get_bits64(). Clean up indentation.Guy Harris1-1/+2
svn path=/trunk/; revision=41228
2012-02-28Fix several messages of type:Jörg Mayer1-6/+6
epan/tvbuff.c: In function ‘tvb_get_bits16’: epan/tvbuff.c:1736:82: error: unused parameter ‘encoding’ [-Werror=unused-parameter] Compilation still fails with: epan/tvbuff.c: In function ‘_tvb_get_bits64’: epan/tvbuff.c:1829:19: error: ‘value’ may be used uninitialized in this function [-Werror=uninitialized svn path=/trunk/; revision=41227
2012-02-28From Mike Morrin:Anders Broman1-214/+96
Overhaul of tvb_get_bitsxx() functions. https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6878 svn path=/trunk/; revision=41226
2012-01-13Fix some Dead Store (Dead assignement/Dead increment) Warning found by ClangAlexis La Goutte1-1/+1
svn path=/trunk/; revision=40473
2011-12-22(Trivial) Indentation, whitespace & formatting cleanup.Bill Meier1-381/+383
svn path=/trunk/; revision=40278
2011-12-21A simplified version of tvbuffs:Bill Meier1-104/+87
- Essentially no changes from current dissector de facto tvbuff usage; - Do away with 'usage_counts' and with 'used_in' GSLists; - Manage tvb chains via a simple doubly linked list. - API changes: a. tvb_increment_usage_count() and tvb_decrement_usage_count() no longer exist; b. tvb_free_chain() can only be called for the 'top-level' (initial) tvb of a chain) or for a tvb not in a chain. c. tvb_free() now just calls tvb_free_chain() [should have no impact on existing dissectors]. svn path=/trunk/; revision=40264
2011-10-23Add a comment about tvb_get_ephemeral_faked_unicode() has been replaced by ↵Bill Meier1-0/+1
tvb_get_ephemeral_unicode_string(). svn path=/trunk/; revision=39528
2011-10-03tvb_get_bits{16,32,64} get passed encoding values. Rename the argumentGuy Harris1-9/+21
appropriately; the only valid encoding is big-endian, so we don't actually do anything different with the argument, so as not to break code that passed it a gboolean endian flag. svn path=/trunk/; revision=39237
2011-09-26Yet another bug fix from Pascal.Anders Broman1-1/+1
svn path=/trunk/; revision=39161
2011-09-26Another bug fix from Pascal.Anders Broman1-1/+1
svn path=/trunk/; revision=39155
2011-09-26From Pascal Quantin:Anders Broman1-7/+25
When building the last byte, the remaining number of bits isn't masked. svn path=/trunk/; revision=39152
2011-09-26Move tvb_new_octet_aligned() to tvbuff.c and use it.Anders Broman1-0/+48
svn path=/trunk/; revision=39150
2011-07-11More GLIB_CHECK_VERSION cleanups. Update the minimum GLib/GTK+ versionsGerald Combs1-36/+0
in README.devloper. Remove g_gnuc.h since it's no longer needed. Remove tvbuff_init(), tvbuff_cleanup(), reassemble_init(), and reassemble_cleanup() since they were only used for older GLib versions which didn't support GSlices. Assume we always support the "matches" operator. svn path=/trunk/; revision=37978
2011-07-05Add some additional routine variants that handle string encodings, andGuy Harris1-7/+26
make FT_STRING and FT_UINT_STRING handle string encodings. Get rid of FT_EBCDIC in favor of FT_STRING with ENC_EBCDIC. Add some URLs for DRDA. Clean up some stuff in TN3270 and TN5250, including using ENC_ values for proto_tree_add_item(). svn path=/trunk/; revision=37909
2011-07-03Add a tvb_get_ephemeral_string_enc() routine that's likeGuy Harris1-5/+17
tvb_get_ephemeral_string() but takes an ENC_ value for the character encoding. Use it in the MQ dissector to fetch strings to put, for example, into the Info column, so we properly handle EBCDIC strings there. svn path=/trunk/; revision=37876
2011-06-16Squelch some compiler warnings.Guy Harris1-1/+1
svn path=/trunk/; revision=37685
2011-05-27Make TVBs opaque for most users.Jeff Morriss1-1/+14
Convert TVB_RAW_OFFSET() and TVB_GET_DS_TVB() into functions. svn path=/trunk/; revision=37422
2011-05-18Fix tvb_get_bits_buf for LSB.Jakub Zawadzki1-3/+8
svn path=/trunk/; revision=37264
2011-05-18- Optimize tvb_get_bits_bufJakub Zawadzki1-11/+41
- Add lsb0 (read: least significant bit is 0) parameter to tvb_get_bits_buf() (not tested, might be buggy...) svn path=/trunk/; revision=37254
2011-05-17Add generic tvb_get_bits_buf() which accepts any no_of_bits.Jakub Zawadzki1-0/+53
svn path=/trunk/; revision=37217
2011-05-12Fix double free. Jakub Zawadzki1-1/+1
compr is also freed outside loop. So free it only when returning. Might be related with bug #5908, but I don't have access to that bug ;-) svn path=/trunk/; revision=37081
2011-04-04From jakub Zawadzki:Anders Broman1-0/+2
I've fixed composite tests #0 and #2 svn path=/trunk/; revision=36440
2011-01-30Fix various instances of "unreachable code".Bill Meier1-2/+0
svn path=/trunk/; revision=35713
2011-01-28Mention that the fake tvb unicode functions have been supercededStephen Fisher1-0/+1
svn path=/trunk/; revision=35689
2011-01-20Fix the dead initialization warnings found by clang's static analysisStephen Fisher1-1/+1
("Value stored to 'xxx' during its initialization is never read") svn path=/trunk/; revision=35598
2011-01-14Add tvb_get_[n|le]toh[40|48|56]() accessors. Addresses bug 5082.Chris Maynard1-0/+54
svn path=/trunk/; revision=35538
2011-01-12There's no need to call tvb_get_ptr() in here: just call ensure_contiguous() ↵Jeff Morriss1-5/+5
directly. svn path=/trunk/; revision=35509
2011-01-12Introduce, and start using, tvb_get_const_stringz(). This function returns aJeff Morriss1-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. svn path=/trunk/; revision=35493