Commit Graph

439 Commits

Author SHA1 Message Date
Guy Harris 30ab019f2b In tvb_get_unicode_string(), if the byte count is odd, ignore the last
byte.  (We should perhaps add an expert info indication in those cases.)

svn path=/trunk/; revision=54074
2013-12-13 22:35:50 +00:00
Guy Harris 562348fbb8 Add ENC_ISO_8859_1.
Move the Wikipedia links for the code page layouts in front of the
tables whose contents reflect the code page layouts.

svn path=/trunk/; revision=53837
2013-12-08 01:05:35 +00:00
Jakub Zawadzki 0e5bc8a49c Add string encoding for ISO/IEC 8859-2 (ENC_ISO_8859_2)
svn path=/trunk/; revision=53826
2013-12-07 15:02:55 +00:00
Jakub Zawadzki 113b078a4d Add new string proto encoding for windows-1250 (ENC_WINDOWS_1250)
- Move windows-1250 to unicode encoding table to charset.c
- Add tvb_get_string_unichar2, tvb_get_stringz_unichar2 functions which recode tvb-string to UTF-8.

svn path=/trunk/; revision=53819
2013-12-07 10:10:03 +00:00
Jakub Zawadzki b3c93326bc Remove #if 0 inverse_bit_mask8 array.
It was only used by tvb_get_bits_buf (removed in r53183).

svn path=/trunk/; revision=53818
2013-12-07 09:14:35 +00:00
Jakub Zawadzki c1ef044de5 Move tvb_uncompress() to tvbuff_zlib.c
svn path=/trunk/; revision=53815
2013-12-06 23:23:44 +00:00
Jakub Zawadzki 5ac6474c94 Rename some of pint.h macros to match common style (bits number on the end).
pntohs  -> pntoh16
   pntohl  -> pntoh32
   pletohs -> pletoh16
   pletohl -> pletoh32
   phtons  -> phton16
   phtonl  -> phton32


svn path=/trunk/; revision=53652
2013-11-29 18:59:06 +00:00
Alexis La Goutte f482d8737f Fix unused-const-variable error when build with clang 3.4
svn path=/trunk/; revision=53512
2013-11-22 14:52:25 +00:00
Jakub Zawadzki ae59b09443 Add missing includes in order to remove exceptions.h from proto.h (next commit).
svn path=/trunk/; revision=53230
2013-11-10 15:59:37 +00:00
Jakub Zawadzki 7b64bcf0b8 Move prototype of bytes_to_str, bytes_to_str_punct to correct header.
svn path=/trunk/; revision=53214
2013-11-10 09:44:02 +00:00
Jakub Zawadzki f207c70075 I have added tvb_get_bits_buf() in r37217, nobody is using it, remove.
svn path=/trunk/; revision=53183
2013-11-09 10:08:58 +00:00
Jakub Zawadzki c86d38af23 Remove old (5 yrs) #if 0 code (from r25028).
svn path=/trunk/; revision=53182
2013-11-09 10:02:39 +00:00
Jakub Zawadzki c011e54567 Fix buildbot, typo:
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-06 21:15:46 +00:00
Jakub Zawadzki 67f69e99e8 tvb: optimize tvb_get_*guid()
we already have valid ptr from ensure_contiguous() so use it to fill structure.

svn path=/trunk/; revision=53113
2013-11-06 20:34:27 +00:00
Jakub Zawadzki b4be2fa489 tvbuff: use always ops->tvb_size
svn path=/trunk/; revision=53112
2013-11-06 20:22:28 +00:00
Jakub Zawadzki d54b3a74f6 tvbuff: cleanup, remove dead code.
ensure_contiguous() will throw exception but won't return NULL.

svn path=/trunk/; revision=53111
2013-11-06 19:03:14 +00:00
Evan Huus 7aee8b2dcf Optimize tvb_ensure_bytes_exist through manual inlining and removal of redundant
checks and computations. Should contain no behavioural changes at *all*, I hope.

svn path=/trunk/; revision=52768
2013-10-22 16:29:10 +00:00
Anders Broman 1684ac969b Revert 52695.
svn path=/trunk/; revision=52763
2013-10-22 14:54:54 +00:00
Anders Broman 09e32f5fb8 Minor optimizations.
svn path=/trunk/; revision=52695
2013-10-19 20:16:00 +00:00
Evan Huus cbe8af0a8b Revert the optimization in r52578. As Jakub predicted, it caused at least one
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-17 12:24:25 +00:00
Evan Huus 934bfff003 Temporarily revert r52651 it caused a regression when trying to tvb_memcpy from
a negative offset (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9277)

svn path=/trunk/; revision=52658
2013-10-17 02:43:21 +00:00
Anders Broman 4223c93c37 Create an internal _tvb_memcpy() without the sanity checks to be caled from tvb internal routines with sanity checks to avoid duplicated checks.
svn path=/trunk/; revision=52651
2013-10-16 20:05:59 +00:00
Evan Huus 2e405d7261 Replace XXX with explanation based on discussion with Jakub on -dev.
svn path=/trunk/; revision=52606
2013-10-14 20:35:56 +00:00
Evan Huus efdbb598b8 So a while back Jeff added some code to check that the offset+length passed to
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-13 04:54:14 +00:00
Evan Huus f65ab9499b Order our conditionals to take advantage of the fact that we know tvb->length <=
tvb->reported_length. Small performance win on the hot path, and a bit easier to
read.

svn path=/trunk/; revision=52577
2013-10-13 00:13:20 +00:00
Evan Huus a11b04b5d8 Tweak/simplify some tvbuff length check functions slightly. In my benchmarks of
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-12 23:41:55 +00:00
Chris Maynard b610734a12 If the offset is out of bounds, have tvb_length_remaining() and 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-10-12 18:13:26 +00:00
Pascal Quantin 102c452bcb More emem -> wmem conversion:
- 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-22 20:04:35 +00:00
Pascal Quantin a0c53ffaa1 emem -> wmem conversion:
- 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-22 15:50:55 +00:00
Evan Huus 6df83e8078 Add _g_ to the names of functions that allocate glib memory. This is a bit more
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-21 17:04:41 +00:00
Evan Huus 9fd46c37a8 - no need for a doubly-linked list of TVBs, single is simpler
- 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-09-07 18:20:52 +00:00
Jakub Zawadzki c27481b03c Fix for bug #9034: Composite TVBs aren't supported by tvb_find_guint8()
Add generic tvb_find_guint8, tvb_pbrk_guint8

svn path=/trunk/; revision=51445
2013-08-20 19:56:57 +00:00
Evan Huus 9fdf6f28e4 Split some asserts so it is more clear what the problem is when they are
triggered.

svn path=/trunk/; revision=51293
2013-08-11 13:44:11 +00:00
Jakub Zawadzki b67492bbc0 Cleanup tvb
- 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-04 22:02:42 +00:00
Jeff Morriss 2df54da6e2 Move a bunch of the crypt modules and pint.h into wsutil.
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-01 23:34:47 +00:00
Jakub Zawadzki 10e40c1638 tvb: check_offset_length() can calculate remaining length, use it.
svn path=/trunk/; revision=51081
2013-08-01 16:54:22 +00:00
Jakub Zawadzki 9d519b5659 Move composite tvbuff to seperate file (with some subtle changes).
svn path=/trunk/; revision=51071
2013-07-31 19:58:13 +00:00
Jakub Zawadzki 761b763eae Move tvb_new_child_real_data() to tvbuff_real.c with some cleanup
svn path=/trunk/; revision=50843
2013-07-23 17:23:51 +00:00
Jakub Zawadzki fec836d697 Fix bug #8936: Fuzz failure: attempt to allocate -1 bytes from 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-15 18:32:11 +00:00
Jakub Zawadzki c766e78cfa Rewrite reassemble API to use TVBs instead of raw data.
(it seems to be working for TCP ^^)

svn path=/trunk/; revision=50580
2013-07-14 14:42:05 +00:00
Jakub Zawadzki 0d85b75305 Move tvb real and subset implementations to seperate files.
svn path=/trunk/; revision=50569
2013-07-14 07:42:19 +00:00
Jakub Zawadzki ef93945811 Add support for cloning TVBs, move tvb_new() prototype to wtap-int.h
svn path=/trunk/; revision=50558
2013-07-13 17:53:33 +00:00
Jakub Zawadzki af61f188e0 Add new function: validate_offset() which checks if offset is within bounds of tvb.
svn path=/trunk/; revision=50556
2013-07-13 14:51:25 +00:00
Jakub Zawadzki d5450ff925 Remove compute_offset_length()
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-13 10:28:19 +00:00
Jakub Zawadzki 614e45a25a Call check_offset_length_no_exception() in tvb_bytes_exist(), fix possible integer overflow
svn path=/trunk/; revision=50550
2013-07-13 09:48:55 +00:00
Jakub Zawadzki cae2ce3b05 TVB: rewrite compute_offset_length(), check_offset_length_no_exception() to 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-13 09:17:32 +00:00
Jakub Zawadzki d2b93398f9 fix subset tvb: we want to do operation on backing tvb on position: 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-12 17:53:51 +00:00
Jakub Zawadzki 356a4613c7 Restore old composite_memcpy() prototype. Remove it from ops.
svn path=/trunk/; revision=50498
2013-07-11 05:51:19 +00:00
Jakub Zawadzki ce81449ed9 packet dissection now takes pointer to tvb instead of guint8 data
implement frame_tvbuff, right now almost a copy of 'real' tvb.

svn path=/trunk/; revision=50497
2013-07-11 05:47:02 +00:00
Jakub Zawadzki 19d2d0dc76 tvbuff: try to fix compilation problems for C++-like compilers.
svn path=/trunk/; revision=50496
2013-07-11 04:35:12 +00:00
Jakub Zawadzki 338f1c9654 tvbuff: remove ->tvb_init() from ops
->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-10 19:25:49 +00:00
Jakub Zawadzki d7175365ab tvbuff: allow tvb-implementations using their own structure (it's fine as long as first member of struct is tvbuff)
Move some stuff outside tvbuff struct.

svn path=/trunk/; revision=50489
2013-07-10 19:08:02 +00:00
Jakub Zawadzki b4d8a3727f Fix previous commit. Devel env with -w in CFLAGS is not so good idea...
svn path=/trunk/; revision=50487
2013-07-10 18:25:24 +00:00
Jakub Zawadzki f3ed13c22e tvbuff: replace type with operation vtable
It's begin of work to allow adding new tvbuff types (think: wtap_tvbuff, base64_tvbuff).

svn path=/trunk/; revision=50486
2013-07-10 18:14:15 +00:00
Jakub Zawadzki 83322789d1 tvbuff: use ep_strbuf_append_unichar()
svn path=/trunk/; revision=50477
2013-07-09 23:10:04 +00:00
Jakub Zawadzki 398f94dd24 tvb subset: move setting tvb->ds_tvb to tvb_new_with_subset()
svn path=/trunk/; revision=50464
2013-07-09 16:22:53 +00:00
Chris Maynard 9a394ddfa0 Get rid of variable, 'end'.
svn path=/trunk/; revision=50285
2013-07-01 06:03:35 +00:00
Chris Maynard 8976968f4c There are a few dissectors that pass the return value of 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-07-01 05:23:17 +00:00
Jeff Morriss 86744b65da As suggested by Jakub: don't ep_alloc buffers for TVBs, use g_malloc()'d
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-05-17 14:38:36 +00:00
Guy Harris 09e0d5b406 When creating a subset tvbuff, inherit the flags from the tvbuff of
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-21 17:38:57 +00:00
Guy Harris 0efcd0632b When we're dissecting the beginning of a fragmented packet that we
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-20 02:53:57 +00:00
Guy Harris 5524d0f801 Pull tvb_init() into tvb_new(); there's no other way to get a new
tvbuff, so we might as well keep all the "here's a new tvbuff" code
together.

svn path=/trunk/; revision=48939
2013-04-19 23:39:35 +00:00
Guy Harris 36dfc6b108 Clean up a bit.
svn path=/trunk/; revision=48937
2013-04-19 18:48:16 +00:00
Guy Harris c0c15029ed Add to tvbuffs a "fragment length" field; if the tvbuff represents the
first fragment of a non-reassembled packet, and we know the length the
packet would have if it were reassembled, this field holds the length of
the fragment, and the "reported length" field shows the length the
packet would have if it were reassembled, so going past the end of the
fragment but staying within the length of the reassembled packet can be
reported as "dissection would have worked if the packet had been
reassembled" rather than "the packet is too short, so it was probably
malformed".

Add a FragmentBoundsError exception, thrown in the "dissection would
have worked if the packet had been reassembled" case.

Add a new tvb_new_subset_length_fragment() routine to create a new
subset tvb with specified fragment and reported lengths.  Use it in the
CLNP dissector.

Add some more sanity checks in the CLNP dissector.

svn path=/trunk/; revision=48917
2013-04-18 19:22:24 +00:00
Pascal Quantin 95938370bd From Ed Beroset via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8416 :
Remove C++ incompatibilities from tvbparse and tvbuff

svn path=/trunk/; revision=48025
2013-03-02 23:05:27 +00:00
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
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
Anders Broman ab16d07fd3 From Vincent Helfre:
Bug in tvb_get_bits32(), The last bitshift is too large, which causes the least significant bits to be 0 all the time.

svn path=/trunk/; revision=35015
2010-11-23 17:33:57 +00:00
Jeff Morriss 0b7e2cd37e Make tvb_strncaseeql()'s size parameter be a size_t. Cast the size to int before calling ensure_contiguous_no_exception() (also in tvb_strneql()).
svn path=/trunk/; revision=34727
2010-10-30 18:53:31 +00:00
Jeff Morriss f5d3a16225 Make tvb_strneql()'s size parameter be a size_t. Remove some now-unnecessary casts.
svn path=/trunk/; revision=34725
2010-10-30 18:18:12 +00:00
Guy Harris cd67ad0047 Clean up indentation.
svn path=/trunk/; revision=33814
2010-08-16 17:19:15 +00:00
Anders Broman 63bffd3ac5 From rodebiet:
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

svn path=/trunk/; revision=33811
2010-08-16 15:13:54 +00:00
Guy Harris 1b444c55fd Refer to the endianness arguments as "encoding" rather than
"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; 

svn path=/trunk/; revision=32929
2010-05-24 06:06:17 +00:00
Anders Broman 1c1142fce6 From Jakub Zawadzki:
- use Glibc:s  highly optimized memchr()

svn path=/trunk/; revision=32584
2010-04-28 08:15:20 +00:00
Anders Broman 4a711cc74a From Jakub Zawadzki:
- optimize guint8_pbrk().

svn path=/trunk/; revision=32583
2010-04-28 07:58:59 +00:00
Bill Meier 6812b68eb1 From Yaniv Kaul: constify parameters
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.

svn path=/trunk/; revision=32365
2010-04-03 18:18:50 +00:00
Bill Meier d32b4c0758 Revert SVN #32360 until Windows compilation errors corrected.
svn path=/trunk/; revision=32361
2010-04-02 15:18:03 +00:00
Bill Meier 049f9eac85 From Yaniv Kaul: constify parameters
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4422

svn path=/trunk/; revision=32360
2010-04-02 14:37:49 +00:00
Anders Broman 25af78517e Make tvb_pbrk_guint8() return the found needle.
svn path=/trunk/; revision=32144
2010-03-08 20:45:13 +00:00
Bill Meier 9d663d7081 Fix various gcc -Wshadow warnings.
svn path=/trunk/; revision=31720
2010-01-28 18:45:46 +00:00
Stig Bjørlykke bb5ef1c521 parent is not unused in tvb_child_uncompress().
svn path=/trunk/; revision=31658
2010-01-25 13:54:05 +00:00
Jaap Keuter 5dcaa2bec0 Make more output parameters optional.
svn path=/trunk/; revision=31059
2009-11-23 22:02:12 +00:00
Gerasimos Dimitriadis 9b36fc784e From yy:
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


svn path=/trunk/; revision=30962
2009-11-14 20:13:43 +00:00
Kovarththanan Rajaratnam dc265696a1 tvb_format_text() always returns a non NULL pointer so don't check return value for NULL pointer
svn path=/trunk/; revision=30821
2009-11-04 16:08:47 +00:00
Kovarththanan Rajaratnam 30cb2b9448 Add DISSECTOR_ASSERT() before dereferencing a possible NULL pointer
svn path=/trunk/; revision=30404
2009-10-08 15:01:25 +00:00
Kovarththanan Rajaratnam 7775703b1a Use g_new0() when allocating z_stream
svn path=/trunk/; revision=30277
2009-10-04 06:32:43 +00:00
Kovarththanan Rajaratnam 911b058d02 Use GLibs CLAMP(). The current inlined implementation seems to be wrong:
} else if (bufsiz > TVB_Z_MAX_BUFSIZ) {
		bufsiz = TVB_Z_MIN_BUFSIZ;
	}

This should probably have been 'bufsiz = TVB_Z_MAX_BUFSIZ;'

svn path=/trunk/; revision=30276
2009-10-04 06:28:50 +00:00
Kovarththanan Rajaratnam 19bf38ac52 Delay allocation of z_stream
svn path=/trunk/; revision=30275
2009-10-04 06:20:32 +00:00
Kovarththanan Rajaratnam 1703bfa464 g_malloc0() doesn't return NULL so remove NULL error paths
svn path=/trunk/; revision=30274
2009-10-04 06:12:31 +00:00
Kovarththanan Rajaratnam c285a1cd3a Remove 'type' formal parameter from tvb_new_with_subset()
svn path=/trunk/; revision=29988
2009-09-20 07:35:39 +00:00
Kovarththanan Rajaratnam b97cfa22fd offset_from_real_beginning() is only called with 0 as second argument, so 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().
svn path=/trunk/; revision=29844
2009-09-10 16:54:02 +00:00
Kovarththanan Rajaratnam fe6f8b92c7 Add a new function, tvb_new_subset_remaining(), which is a sligtly optimized 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.

svn path=/trunk/; revision=29445
2009-08-16 10:53:47 +00:00
Kovarththanan Rajaratnam c795851beb Remove unused parameters
svn path=/trunk/; revision=29444
2009-08-16 09:48:25 +00:00
Kovarththanan Rajaratnam 6cd59f3799 Remove the non-thread safe usage of 'last_tvb' variable in tvb_new_subset()
svn path=/trunk/; revision=29443
2009-08-16 09:18:17 +00:00
Kovarththanan Rajaratnam 998ee3a2e0 Make some of the check_XXX functions accept the length/reported length of 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()
svn path=/trunk/; revision=29442
2009-08-16 08:18:17 +00:00
Kovarththanan Rajaratnam 01abc372e6 Remove a non thread-safe usage (useful when/if we ever support threading) of 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.
svn path=/trunk/; revision=29441
2009-08-16 07:29:11 +00:00
Kovarththanan Rajaratnam aed905a6c9 Use the slice allocator if GLIB >= 2,10,0 as suggested by Anders Broman
svn path=/trunk/; revision=29434
2009-08-15 13:24:59 +00:00
Kovarththanan Rajaratnam 623db2e71e Add a missing DISSECTOR_ASSERT in tvb_init()
svn path=/trunk/; revision=29433
2009-08-15 12:41:24 +00:00
Kovarththanan Rajaratnam ef68d63745 Make mem chunk static
svn path=/trunk/; revision=29432
2009-08-15 12:29:25 +00:00
Kovarththanan Rajaratnam e1c5ffd553 (Trivial change) move ensure_contiguous() to reflect call hierarchy
svn path=/trunk/; revision=29382
2009-08-11 18:28:10 +00:00
Kovarththanan Rajaratnam 158827a5e7 Turn a comment in fast_ensure_contiguous() into a DISSECTOR_ASSERT() to make the implied requirement explicit.
svn path=/trunk/; revision=29381
2009-08-11 18:16:55 +00:00
Stig Bjørlykke 81c551ec59 Remove some "statement not reached" warnings.
svn path=/trunk/; revision=28691
2009-06-11 10:03:08 +00:00
Stig Bjørlykke a44cc2442d Fixed check for no_of_bits in tvb_get_bits16(), tvb_get_bits32() and
tvb_get_bits64().

svn path=/trunk/; revision=28658
2009-06-08 08:28:42 +00:00
Stig Bjørlykke d628c0a4cc Added tvb_format_stringzpad_wsp().
svn path=/trunk/; revision=28140
2009-04-24 08:08:37 +00:00
Guy Harris 8b7812db76 Reapply the change from revision 27946.
svn path=/trunk/; revision=27963
2009-04-05 17:24:06 +00:00
Gerald Combs 17ae564af8 Back out the previous change. As Guy pointed out, we might not want to
be so size_t-happy.

svn path=/trunk/; revision=27962
2009-04-05 16:26:16 +00:00
Gerald Combs 098eb5606f tvbuff.[ch]: Accept more size_t's.
packet-wcp.c: Add size_t casts.
packet-x11.c: Use string buffers.

svn path=/trunk/; revision=27959
2009-04-04 19:34:06 +00:00
Guy Harris 1f96f14083 Don't support a length of -1 meaning "to the end of the tvbuff" in
tvb_memcpy(); I changed the one tvb_memcpy() call that was explicitly
depending on that not to do so.  This is a small step towards getting
rid of the "-1 means to end of tvbuff" convention, support for which
requires us to do a bunch of extra checks where, for example, a protocol
has a 32-bit unsigned length field; it also gets rid of a warning about
comparing an unsigned value with a signed value.

svn path=/trunk/; revision=27946
2009-04-03 17:04:45 +00:00
Gerald Combs 342a836bba Make the "length" argument of the tvb_mem* functions a size_t since it's
not uncommon to pass them the result of pointer arithmetic. Add size_t
casts in other areas.

svn path=/trunk/; revision=27941
2009-04-03 15:30:38 +00:00
Anders Broman 4ba5d2f92b Add to new functions from the optimization patch:
tvb_child_uncompress()
tvb_new_child_real_data()

svn path=/trunk/; revision=27924
2009-04-01 16:22:51 +00:00
Stephen Fisher 1a71ec7c45 Introduce two new functions:
tvb_get_seasonal_string();
  tvb_get_seasonal_stringz();

.. which work the same as the ephemeral versions of the functions, but use
se_alloc() instead of ep_alloc().


svn path=/trunk/; revision=27868
2009-03-27 19:40:23 +00:00
Stig Bjørlykke 62f60df6b4 From Jakub Zawadzki (bug 3331):
g_free() is NULL safe, so we don't need check against it.

svn path=/trunk/; revision=27718
2009-03-13 22:06:48 +00:00
Jeff Morriss 73f7073540 Fix https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=2649 by adding some length checks to two while loops in tvb_uncompress()
svn path=/trunk/; revision=25677
2008-07-08 20:04:11 +00:00
Gerald Combs 8db852e950 Port over the composite tvbuff fixes from /trunk-1.0.
svn path=/trunk/; revision=25498
2008-06-20 20:33:38 +00:00
Jörg Mayer 944beafd70 Get rid of some unsued code: The warning causes a failure due to -Werror
svn path=/trunk/; revision=25028
2008-04-14 21:31:19 +00:00
Anders Broman 4073fa0deb From Michael McCartney:
patch for tvb_get_bits16 not to read past end of buffer
http://bugs.wireshark.org/bugzilla/show_bug.cgi?id=2439

svn path=/trunk/; revision=24942
2008-04-12 17:00:41 +00:00
Anders Broman 63c5c71cf8 Remove:
#ifdef NEED_G_ASCII_STRCASECMP_H
#include "g_ascii_strcasecmp.h"
#endif

svn path=/trunk/; revision=24859
2008-04-09 05:36:08 +00:00
Ashok Narayanan 7fe3f42d5a Fixed bug with tvb_get_bits64(); the mask array had one less "ff" than
it needs. This manifests itself in calls to tvb_get_bits64() and in
calls to proto_tree_add_bits_xxx() for >32 bits.



svn path=/trunk/; revision=24726
2008-03-25 18:53:17 +00:00
Stig Bjørlykke 6193d9d3c2 Add a inflateEnd() call to free up the stream in the re-init block.
svn path=/trunk/; revision=24559
2008-03-04 22:56:26 +00:00
Anders Broman 4d01fd05cb tvbuff.c - fix abug if reading last byte in tvb
Further H.264 decoding in SDP

svn path=/trunk/; revision=23847
2007-12-12 21:50:14 +00:00
Anders Broman e5f48395f1 Move the routines tvb_skip_wsp() to tvbuff.c
svn path=/trunk/; revision=23818
2007-12-09 17:41:16 +00:00
Guy Harris 9c89cdaaa3 strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est.  Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).

In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.

We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot.  This causes strings that should
match not to match.

This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.

svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
Anders Broman d24d657f75 Add {} to some IF statements.
svn path=/trunk/; revision=23468
2007-11-16 09:00:14 +00:00
Anders Broman 1143ab41b1 Apply yet another set of the optimization patches:
- Use a fast path for the most common use of tvb_get_xxx functions:
offset is >= 0 and tvb->real_data is set (this one is always true).
- match_strval() is a linear search, put the most common protocols
TCP/UDP/RDP first.
- fix gtk1 g_strlcat declaration Use g_strlcat

svn path=/trunk/; revision=23285
2007-10-27 14:44:29 +00:00
Guy Harris 0300ebc04a Get rid of unused variables.
Wrap 64-bit constants in G_GINT64_CONSTANT(), so they get the
appropriate suffix appended so the compiler knows they're 64 bits.

svn path=/trunk/; revision=21832
2007-05-19 03:45:39 +00:00
Anders Broman b688f9154a Split tvb_get_bits64 into tvb_get_bits8 tvb_get_bits16 tvb_get_bits32 and tvb_get_bits64
and use them in proto_tree_add_bits_ret_val().

svn path=/trunk/; revision=21828
2007-05-18 16:46:35 +00:00
Martin Mathieson 7510f41080 Fix proto_tree_add_bits_ret_val() (as now used by FP dissector).
Note that FP uses this function in a limited way, but this fixes problems seen.

svn path=/trunk/; revision=21727
2007-05-08 17:17:51 +00:00
Guy Harris ed652180e6 NULL is a pointer value; routines returning integral values shouldn't
return NULL.

svn path=/trunk/; revision=21613
2007-04-28 22:01:27 +00:00
Guy Harris b19c9f63e9 Make tvb_memdup(), like ep_tvb_memdup(), return a "void *".
svn path=/trunk/; revision=21610
2007-04-28 21:06:15 +00:00
Anders Broman 43bb2aea51 Add:
proto_tree_add_bits_ret_val()
tvb_get_bits()
And modify
proto_tree_add_bits() not to return a value.
little endian is not yet implemented.

svn path=/trunk/; revision=21607
2007-04-28 12:13:25 +00:00
Guy Harris 8ff20a50ce Fix definition of tvb_memcpy() to match declaration.
svn path=/trunk/; revision=21555
2007-04-24 17:12:29 +00:00
Guy Harris 6f8cee8acd "memcpy()" takes void *'s as arguments and returns a void *; have
tvb_memcpy() be similar, to avoid unnecessarily alignment warnings.

Do the same with "ep_tvb_memdup()".

svn path=/trunk/; revision=21554
2007-04-24 11:54:18 +00:00
Guy Harris adcccbcdee More const cleanup.
svn path=/trunk/; revision=21535
2007-04-23 18:18:08 +00:00
Guy Harris 56fcbf41be The "needles" argument of guint8_pbrk() needs to be const, as that's
what's passed to it.

svn path=/trunk/; revision=21531
2007-04-23 17:37:36 +00:00
Guy Harris 1bc049906a Add some GCC warnings to the standard set, and add some others to the
--enable-extra-gcc-checks set.

If we turn on -pedantic, try turning on -Wno-long-long as well, so that
it's not *so* pedantic that it rejects the 64-bit integral data types
that we explicitly require.

Constify a bunch of stuff, and make some other changes, to get rid of
warnings.

Clean up some indentation.

svn path=/trunk/; revision=21526
2007-04-23 10:59:26 +00:00
Gerald Combs 9022de04b1 Make our tvb exists before we try to dereference it. Fixes some of the
current fuzz errors.

svn path=/trunk/; revision=18665
2006-07-05 18:47:21 +00:00
Anders Broman 764e3ac167 New rutine tvb_format_text_wsp() which will change "whiite space" characters to space
before output.

svn path=/trunk/; revision=18519
2006-06-19 15:53:03 +00:00
Ronnie Sahlberg 89f022b12b name change
svn path=/trunk/; revision=18197
2006-05-21 05:12:17 +00:00