Commit Graph

92 Commits

Author SHA1 Message Date
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
Tomas Kukosa bb39c4f7a6 add guid-utils.h to Makefile.common
remove unused variables from tvbuff.c

svn path=/trunk/; revision=17567
2006-03-10 12:57:22 +00:00
Tomas Kukosa 923855bb20 new FT_GUID handling - big/little endian supported
svn path=/trunk/; revision=17566
2006-03-10 11:58:22 +00:00
Guy Harris 6f38a35500 Add some inflateEnd() calls to free up stuff associated with a stream
before freeing the stream; bug 659 mentioned one of them, but there
appear to be others.

svn path=/trunk/; revision=16973
2006-01-07 03:36:37 +00:00
Ulf Lamping 3fd9edbf10 as tvb functions are frequently used by a lot of dissectors, use DISSECTOR_ASSERT() like instead of g_assert throughout tvbuff, so a malicious dissector won't crash Ethereal (at least at the ways we can detect it)
of course this won't catch e.g. NULL pointers, but far better than nothing ...

svn path=/trunk/; revision=15980
2005-09-23 18:27:30 +00:00
Ulf Lamping 76b09b1fee assert that tvb is not NULL
svn path=/trunk/; revision=15858
2005-09-18 20:11:54 +00:00
Guy Harris 25c4bc9379 Replace tvb_memcpy() calls that extract IPv4 addresses into a guint32,
and that extract IPv6 addresses into a "struct e_in6_addr", with
tvb_get_ipv4() and tvb_get_ipv6() calls - except for some that we
remove, by using proto_tree_add_item(), rather than replacing.

Have epan/tvbuff.h include epan/ipv6-utils.h, to define "struct
e_in6_addr" (not necessary to declare the tvbuff routines, but including
it there means "struct e_in6_addr" is guaranteed to be defined before
those declarations, so we don't get compiler complaints if we define it
*after* those declarations).

svn path=/trunk/; revision=15758
2005-09-11 21:25:37 +00:00
Guy Harris 266e1a3491 Add "tvb_get_ipv4()" and "tvb_get_ipv6()" addresses, to fetch IPv4 and
IPv6 addresses.  Use "tvb_get_ipv4()" in the WINS Replication dissector,
so that it gets the right answer on little-endian *AND* big-endian
machines.

svn path=/trunk/; revision=15753
2005-09-10 19:43:41 +00:00
Ulf Lamping 495eb1b788 snprintf -> g_snprintf
svn path=/trunk/; revision=15398
2005-08-17 23:10:28 +00:00
Ronnie Sahlberg 9599cf9e3b add new function tvb_get_ephemeral_stringz()
svn path=/trunk/; revision=15273
2005-08-10 14:25:59 +00:00
Ronnie Sahlberg b4441e6748 rename ep_tvb_fake_unicode() to tvb_get_ephemeral_faked_unicode() and update the README file.
svn path=/trunk/; revision=15271
2005-08-10 13:56:34 +00:00
Ronnie Sahlberg ec3ab9ec3e rename ep_tvb_get_string() to tvb_get_ephemeral_string() asnd update the documentation in README.developer
svn path=/trunk/; revision=15270
2005-08-10 13:41:13 +00:00
Ronnie Sahlberg 93c4543207 add an ep version of tvb_fake_unicode()
svn path=/trunk/; revision=15128
2005-07-28 08:55:11 +00:00
Luis Ontanon c5688891a1 new functions:
ep_tvb_memdup()
ep_alloc0()
ep_strsplit()

add all of the ep_ allocators to libethereal.def

svn path=/trunk/; revision=15100
2005-07-26 18:32:12 +00:00
Ronnie Sahlberg 0d385f730f add
ep_tvb_get_string
that acts the same as tvb_get_string   but the buffer returned need not be freed.



svn path=/trunk/; revision=15024
2005-07-24 01:56:01 +00:00
Gerald Combs c9bc1edd92 When trying to handle gzip-compressed data, don't seek past the end of our
compressed data buffer.  Fixes bug 288.

svn path=/trunk/; revision=14981
2005-07-21 21:40:57 +00:00
Gerald Combs 618b8887dc Use tvb_ensure_bytes_exist() in tvb_get_string() instead of throwing an
exception ourselves.  Fixes bug 130.

svn path=/trunk/; revision=14220
2005-04-28 18:07:40 +00:00
Gerald Combs 131ab36a32 In tvb_get_string(), throw an exception if our length is less than zero.
Add a message block length check to the AIM dissector.

svn path=/trunk/; revision=13955
2005-03-28 15:55:47 +00:00
Guy Harris 5474a467a2 From Chris Maynard: free up the z_stream we've allocated before failure
returns.  (The error returns shouldn't happen in practice, as the GLib
memory allocators never return a null pointer, they just abort the
program, but if we're going to be checking for failure and returning, we
should do the right thing anyway.)

svn path=/trunk/; revision=12957
2005-01-05 10:19:36 +00:00
Guy Harris a0de9d34c7 Add a "tvb_bytes_to_str_punct()" routine, which wraps
"bytes_to_str_punct()", and use it instead of extracting the bytes and
formatting them by hand.

svn path=/trunk/; revision=12876
2004-12-30 23:47:52 +00:00
Guy Harris a3f3ea6dbe From Charles Levert: in "tvb_fake_unicode()", convert non-ASCII
characters to '.'.

svn path=/trunk/; revision=12515
2004-11-12 10:26:56 +00:00
Guy Harris c68f62210f Add "tvb_get_ntoh64()" and "tvb_get_letoh64()" routines to fetch 64-bit
integers.

Make FT_INT64 and FT_UINT64 add numerical values, rather than byte-array
values, to the protocol tree, and add routines to add specified 64-bit
integer values to the protocol tree.

Use those routines in the RSVP dissector.

svn path=/trunk/; revision=11796
2004-08-22 00:31:58 +00:00
Guy Harris cb0506f41b Most developers have only 10 fingers, not 16. :-)
svn path=/trunk/; revision=11581
2004-08-02 18:58:19 +00:00
Olivier Biot c3ccccf2b6 From Kelly Byrd: fix tvb_uncompress() for GZIP encoded content.
svn path=/trunk/; revision=11579
2004-08-02 09:15:58 +00:00
Guy Harris 8a8b883450 Set the svn:eol-style property on all text files to "native", so that
they have LF at the end of the line on UN*X and CR/LF on Windows;
hopefully this means that if a CR/LF version is checked in on Windows,
the CRs will be stripped so that they show up only when checked out on
Windows, not on UN*X.

svn path=/trunk/; revision=11400
2004-07-18 00:24:25 +00:00
Olivier Biot 687f3af0f2 From Jerry Talkington: speed up tvb_uncompress() by increasing the minimal
and default uncompression buffer.

svn path=/trunk/; revision=10839
2004-05-10 22:14:07 +00:00
Olivier Biot 463597f54a Memory management of tvb_uncompress() needs tvb_set_free_cb().
svn path=/trunk/; revision=10817
2004-05-07 18:15:24 +00:00
Olivier Biot 77449b1085 From Kendy Kutzner: a char should be compared with '\0', not NULL.
svn path=/trunk/; revision=10806
2004-05-06 17:40:52 +00:00
Olivier Biot 659ac78357 From Jerry Talkington:
- Helper functions for uncompressing compressed tvbuffers.

	- Compressed content coding dissection in HTTP.

svn path=/trunk/; revision=10799
2004-05-05 06:55:09 +00:00
Guy Harris 834543d7c7 Use "tvb_format_text()" to display strings, so we handle non-printable
characters.

Some strings appear to be null-padded; add a "tvb_format_stringzpad()"
routine to handle them, so that we don't show the padding characters as
"\000".

svn path=/trunk/; revision=10461
2004-03-23 18:06:29 +00:00
Guy Harris d09c4c4eab Constify a bunch of stuff.
svn path=/trunk/; revision=10106
2004-02-19 05:19:10 +00:00
Guy Harris 87b219554e Make "tvb_strneql()" take a "gchar *" rather than a "guint8 *" as the
string argument.

Add some casts to squelch compiler warnings.

svn path=/trunk/; revision=9951
2004-02-01 21:30:17 +00:00
Jörg Mayer 38faa0f27b packet-dcerpc-afs4int.c
svn path=/trunk/; revision=9938
2004-02-01 06:49:25 +00:00
Jörg Mayer 11e10e61fd Change return type of tvb_format_text from guint8* to gchar*.
Remove now unnecessary casts in two files.

svn path=/trunk/; revision=9801
2004-01-23 09:40:38 +00:00
Guy Harris 129de02c79 In "tvb_ensure_bytes_remaining()", throw ReportedBoundsError, not
BoundsError, if the offset is just past the end of the reported data
(because we're ensuring that there actually *is* a byte there, and,
even according to the reported length, it isn't).

svn path=/trunk/; revision=9444
2003-12-24 23:28:17 +00:00
Guy Harris 821baa3d48 Have "tvb_ensure_length_remaining()" throw the appropriate exception if
there's no data remaining - its callers largely depend on it doing so.

That means that the BEEP dissector doesn't have to check for it
returning 0.

svn path=/trunk/; revision=9433
2003-12-23 21:22:00 +00:00
Ronnie Sahlberg 9c14c51834 Replace two expensive macros with a much simpler mechanism
to prevent memory leaks due to exceptions.

makes my tethereal testcase ~1% faster.

svn path=/trunk/; revision=9153
2003-12-03 10:14:34 +00:00
Ronnie Sahlberg 5ff0237060 performance update
replace tvb_raw_offset() which is essentially a simple assignment and which
is called a lot with a macro.

this makes my tethereal testcase 2-3% faster.

svn path=/trunk/; revision=9152
2003-12-03 09:50:40 +00:00
Ronnie Sahlberg bfaca0cab6 Move the definition of the tvbuff_t structure and friends to tvbuff.h
so that we can change tvb_get_ds_tvb() into a macro.

This function was a single line assignment and was called a lot.

This made tethereal ~2.5% faster in one testcase I use.

svn path=/trunk/; revision=9141
2003-12-02 10:23:18 +00:00
Guy Harris b530c88a3b "compute_offset_length()" must, if it returns FALSE, and "exception" is
non-null, set "*exception" to the appropriate exception - its callers
rely on it.

Now that it does that, there's no need for "check_offset_length()" to
check for a length of -1, as "compute_offset_length()" does so, and
therefore "check_offset_length_no_exception()" does so.

svn path=/trunk/; revision=8562
2003-09-28 21:39:53 +00:00
Gerald Combs 7704cdd149 Make tvb_find_tvb() return -1 if either tvb length is 0. Otherwise, an
assertion happens 'xxxx contains ""'.

svn path=/trunk/; revision=8450
2003-09-10 21:19:47 +00:00
Gilbert Ramirez 52338a3baf Add a "contains" operator for byte-strings, strings, and tvbuffs (protocols).
The search uses a naive approach; more work is required to add a
Boyer-Moore Search algorithm.

svn path=/trunk/; revision=8280
2003-08-27 15:23:11 +00:00
Guy Harris 663a127b5d A bufsize of 0 makes no sense in either "tvb_get_nstringz()" or
"tvb_get_nstringz0()", as it means there's no room even for the
terminating NUL; abort if "_tvb_get_nstringz()" is passed a bufsize of
0.

Don't throw an exception in "tvb_get_nstringz0()" if
"_tvb_get_nstringz()" returns 0 - that just means we have an empty
string.

svn path=/trunk/; revision=8150
2003-08-08 08:19:50 +00:00
Guy Harris ee97ce3196 Add new routines:
tvb_get_string() - takes a tvbuff, an offset, and a length as
	arguments, allocates a buffer big enough to hold a string with
	the specified number of bytes plus an added null terminator
	(i.e., length+1), copies the specified number of bytes from the
	tvbuff, at the specified offset, to that buffer and puts in a
	null terminator, and returns a pointer to that buffer (or throws
	an exception before allocating the buffer if that many bytes
	aren't available in the tvbuff);

	tvb_get_stringz() - takes a tvbuff, an offset, and a pointer to
	a "gint" as arguments, gets the size of the null-terminated
	string starting at the specified offset in the tvbuff (throwing
	an exception if the null terminator isn't found), allocates a
	buffer big enough to hold that string, copies the string to that
	buffer, and returns a pointer to that buffer and stores the
	length of the string (including the terminating null) in the
	variable pointed to by the "gint" pointer.

Replace many pieces of code allocating a buffer and copying a string
with calls to "tvb_get_string()" (for one thing, "tvb_get_string()"
doesn't require you to remember that the argument to
"tvb_get_nstringz0()" is the size of the buffer into which you're
copying the string, which might be the length of the string to be copied
*plus 1*).

Don't use fixed-length buffers for null-terminated strings (even if the
code that generates those packets has a #define to limit the length of
the string).  Use "tvb_get_stringz()", instead.

In some cases where a value is fetched but is only used to pass an
argument to a "proto_tree_add_XXX" routine, use "proto_tree_add_item()"
instead.

svn path=/trunk/; revision=7859
2003-06-12 08:33:32 +00:00
Guy Harris 6b36f382ad Fix "tvb_strneql()", "tvb_strncaseeql()", and "tvb_memeql()" not to
throw an exception if there aren't enough bytes in the tvbuff to
compare.

svn path=/trunk/; revision=7813
2003-06-09 07:27:42 +00:00
Guy Harris dd6f38957b Use "tvb_ensure_bytes_exist()" to check, in "tvb_fake_unicode()", to
make sure we have the entire string, rather than fetching the last
character.

svn path=/trunk/; revision=7783
2003-06-04 21:45:49 +00:00
Gerald Combs 7a132e5b48 More tvb_get_nstringz0() fixes. Timo Sirainen pointed out that Bad
Things can happen if we pass a zero buffer length to tvb_get_nstringz0().
Throw an exception if this happens.

In various dissectors make sure the tvb_get_nstringz0()'s buffer length
is greater than zero.

svn path=/trunk/; revision=7688
2003-05-19 03:23:12 +00:00
Gerald Combs 0b9bbbbdb6 Modify tvb_get_nstringz*() to behave more like snprintf(). Make changes
where necessary to reflect the new behavior.

svn path=/trunk/; revision=7607
2003-04-30 02:35:28 +00:00