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
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
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
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
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
- 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
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
+ 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
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
->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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
- 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
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
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
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
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
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
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
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
/*
* 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
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
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
"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
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
} 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
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
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
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
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
- 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
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
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
--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