Commit Graph

224 Commits

Author SHA1 Message Date
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
Jakub Zawadzki 2919ac5a5e Add some explation about buffer size.
svn path=/trunk/; revision=43266
2012-06-14 20:13:45 +00:00
Jakub Zawadzki 0711ac874f Optimize tvb_*_unicode functions.
- 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-06-14 19:08:19 +00:00
Gerald Combs 21b3256918 Assign some variables that scan-build was complaining about.
svn path=/trunk/; revision=42638
2012-05-15 21:56:02 +00:00
Guy Harris 1c2a67f348 Make the encoding argument uniformly guint rather than gint.
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-15 05:42:58 +00:00
Jakub Zawadzki 0f1a21aaa9 tvb_unicode_strsize() returns number of bytes, NOT number of UCS-2 characters.
svn path=/trunk/; revision=42622
2012-05-14 06:32:16 +00:00
Guy Harris 14b616c35d Get rid of remaining Booleans-as-encoding-arguments in
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-14 00:49:05 +00:00
Guy Harris 7a87d7b6a3 Add ENC_UTF_16 and ENC_UCS_2. Note that UTF-16 and UCS-2 are not the
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-05-11 23:55:54 +00:00
Anders Broman b02b6a932f From Evan Huus: Use Add DISSECTOR_ASSERT_HINT() macro. https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7142
svn path=/trunk/; revision=42148
2012-04-20 05:12:20 +00:00
Jakub Zawadzki 68ec58d385 Fix some: 'cast discards qualifiers from pointer target type' warnings
- Add const qualifier
- Remove some strange casts

svn path=/trunk/; revision=42131
2012-04-18 12:35:36 +00:00
Anders Broman 5d101caa89 From Martin Kaiser: CID 525 is about tvb_new_octet_aligned(). datalen can be 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-12 05:36:26 +00:00
Gerald Combs 1db28ae469 Clamp a value as suggested by Mike Morrin in bug 6878.
svn path=/trunk/; revision=41968
2012-04-06 00:32:26 +00:00
Gerald Combs 8b3024e57c Make bit_offset in _tvb_get_bits64 and related functions unsigned. This
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-04-04 21:54:22 +00:00
Jakub Zawadzki 35eae45497 These buffers in tvb_uncompress() can't ovelaps, so use optimized memcpy().
svn path=/trunk/; revision=41870
2012-03-31 12:35:07 +00:00
Jakub Zawadzki 60f47ed05b Fix for bug #6480 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6480)
Yay, first commit since r37883 (almost 9months).

svn path=/trunk/; revision=41869
2012-03-31 12:33:10 +00:00
Bill Meier d4c21b2123 From Mike Morrin: Fix for "The previous patch had an error and was returning 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-28 20:32:42 +00:00
Guy Harris b474b4006c Initialize "value" in _tvb_get_bits64(). Clean up indentation.
svn path=/trunk/; revision=41228
2012-02-28 18:31:19 +00:00
Jörg Mayer 294e0e98f6 Fix several messages of type:
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-28 17:44:49 +00:00
Anders Broman 075bd9f86a From Mike Morrin:
Overhaul of tvb_get_bitsxx() functions.

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6878

svn path=/trunk/; revision=41226
2012-02-28 16:29:07 +00:00
Alexis La Goutte 99c039e0d3 Fix some Dead Store (Dead assignement/Dead increment) Warning found by Clang
svn path=/trunk/; revision=40473
2012-01-13 16:36:07 +00:00
Bill Meier 1e89640004 (Trivial) Indentation, whitespace & formatting cleanup.
svn path=/trunk/; revision=40278
2011-12-22 18:13:18 +00:00
Bill Meier 14309d2c72 A simplified version of tvbuffs:
- 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-12-21 17:39:02 +00:00
Bill Meier ed79560623 Add a comment about tvb_get_ephemeral_faked_unicode() has been replaced by tvb_get_ephemeral_unicode_string().
svn path=/trunk/; revision=39528
2011-10-23 22:02:56 +00:00
Guy Harris 330fd51e8e tvb_get_bits{16,32,64} get passed encoding values. Rename the argument
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-10-03 06:12:11 +00:00
Anders Broman 02cba4defa Yet another bug fix from Pascal.
svn path=/trunk/; revision=39161
2011-09-26 21:06:55 +00:00
Anders Broman f54cc3fcb7 Another bug fix from Pascal.
svn path=/trunk/; revision=39155
2011-09-26 18:56:27 +00:00
Anders Broman 75b86a9cd4 From Pascal Quantin:
When building the last byte, the remaining number of bits isn't masked.

svn path=/trunk/; revision=39152
2011-09-26 17:19:54 +00:00
Anders Broman 5f76488f0a Move tvb_new_octet_aligned() to tvbuff.c and use it.
svn path=/trunk/; revision=39150
2011-09-26 15:11:14 +00:00
Gerald Combs 49b92440de More GLIB_CHECK_VERSION cleanups. Update the minimum GLib/GTK+ versions
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-11 20:32:19 +00:00
Guy Harris 053c583fda Add some additional routine variants that handle string encodings, and
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-05 23:59:23 +00:00
Guy Harris 338af96b2e Add a tvb_get_ephemeral_string_enc() routine that's like
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-07-03 17:08:25 +00:00
Guy Harris 4447b23f6b Squelch some compiler warnings.
svn path=/trunk/; revision=37685
2011-06-16 18:34:17 +00:00
Jeff Morriss f3f9f2697f Make TVBs opaque for most users.
Convert TVB_RAW_OFFSET() and TVB_GET_DS_TVB() into functions.

svn path=/trunk/; revision=37422
2011-05-27 03:06:50 +00:00
Jakub Zawadzki 7e3bbb2784 Fix tvb_get_bits_buf for LSB.
svn path=/trunk/; revision=37264
2011-05-18 21:33:05 +00:00
Jakub Zawadzki 3bb5e937d4 - Optimize tvb_get_bits_buf
- 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-18 18:49:33 +00:00