Commit Graph

210 Commits

Author SHA1 Message Date
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
Jakub Zawadzki e21e71e46e Add generic tvb_get_bits_buf() which accepts any no_of_bits.
svn path=/trunk/; revision=37217
2011-05-17 22:20:14 +00:00
Jakub Zawadzki 12d8f46860 Fix double free.
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-05-12 16:31:42 +00:00
Anders Broman 6cef8aa872 From jakub Zawadzki:
I've fixed composite tests #0 and #2

svn path=/trunk/; revision=36440
2011-04-04 05:48:06 +00:00
Bill Meier 7f0107220d Fix various instances of "unreachable code".
svn path=/trunk/; revision=35713
2011-01-30 23:27:57 +00:00
Stephen Fisher d37c33b7e7 Mention that the fake tvb unicode functions have been superceded
svn path=/trunk/; revision=35689
2011-01-28 20:01:01 +00:00
Stephen Fisher fc7b0c019b Fix the dead initialization warnings found by clang's static analysis
("Value stored to 'xxx' during its initialization is never read")


svn path=/trunk/; revision=35598
2011-01-20 18:56:11 +00:00
Chris Maynard 116d67e164 Add tvb_get_[n|le]toh[40|48|56]() accessors. Addresses bug 5082.
svn path=/trunk/; revision=35538
2011-01-14 19:02:38 +00:00
Jeff Morriss 05400b7709 There's no need to call tvb_get_ptr() in here: just call ensure_contiguous() directly.
svn path=/trunk/; revision=35509
2011-01-12 20:25:36 +00:00
Jeff Morriss 0c4e881911 Introduce, and start using, tvb_get_const_stringz(). This function returns a
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
2011-01-12 02:25:08 +00:00
Stephen Fisher 55e08f007e Introduce two new functions for Unicode (UTF-16) string handling:
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.


svn path=/trunk/; revision=35344
2011-01-03 18:29:29 +00:00
Anders Broman 735709bee6 Add tvb_bcd_dig_to_ep_str()
/*
 * 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.
 */

svn path=/trunk/; revision=35286
2010-12-28 12:36:26 +00:00
Stephen Fisher e9f3d27b4a Add a couple more comments to new unicode function to remind us when a
variable is counting UTF-16 characters vs. normal bytes.


svn path=/trunk/; revision=35256
2010-12-23 18:26:25 +00:00
Stephen Fisher f0029fd060 Remove comment to myself that I forgot to remove before commiting r35253
and change comments to fit within 80 column display.


svn path=/trunk/; revision=35255
2010-12-23 18:24:39 +00:00
Stephen Fisher 4f5ccc00f8 Introduce new function called tvb_get_ephemeral_unicode_stringz(), which
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.


svn path=/trunk/; revision=35253
2010-12-23 17:59:34 +00:00