Commit Graph

27 Commits

Author SHA1 Message Date
John Thacker 4e184104af exceptions: Add an expert warning for FragmentBoundsError
FragmentBoundsErrors aren't malformed, but add an expert warning
at the PI_NOTE level to hint to users that they may want to turn
on reassembly preferences.
2022-04-06 07:17:14 -04:00
John Thacker fad8346282 exceptions: set FragmentBoundsError priority above ContainedBoundsError
All fragment errors are bounds errors that go past the contained length,
but they do not necessarily involve going past the reported length,
so the checks for FragmentBoundsError should reflect that.

With some forms of reassembly, like IP fragmentation, we don't know how
big the PDU/reassembled packet is until reassembly is complete, so we
probably use tvb_new_subset_remaining() to create fragments and the tvb's
reported length is equal to its contained length. In these cases
ReportedBoundsError would be otherwise thrown, except when the existing
checks for FragmentBoundsError intervene.

However, with other forms of reassembly, like various PDUs carried over TCP,
we know the total PDU length, so we use tvb_new_subset_length[_caplen](),
setting the proper reported length, but not changing the contained
length when reassembly is not performed. In those cases, a bounds error
that occurs due to lack of reassembly is otherwise a ContainedBoundsError,
not a ReportedBoundsError.

In both cases, a bounds error caused by an unreassembled fragment should
be a FragmentBoundsError for the existing reasons. It is not necessarily
a malformed packet (to the extent reassembly is not performed because of a
malformed error elsewhere, that should be reported separately) and can
likely be avoided by changing preferences (e.g., turning reassembly
preferences on, turning off checksum verification, etc.) Otherwise it
is probably a dissector bug.
2021-10-23 15:42:10 +00:00
Guy Harris 98b72220f4 Remove uninteresting information from REPORT_DISSECTOR_BUG() etc. messages.
ws_warning() logs the source file name, source line number, and calling
function name for the ws_warning() call; for errors reported by
REPORT_DISSECTOR_BUG() and macros that call it, the message isn't
reported directly by the macro - the macro formats the error message
into a string, saves the string, and throws a DissectorError exception,
to terminate the dissection, and the exception handler uses the
formatted string in its messages.

Thus, the location in the exception handler isn't interesting; it's not
where the error occurred, it's just where the message is logged, which i
the same for all such errors.

Don't use ws_warning(); instead, directly call ws_log() with
WS_LOG_DOMAIN and LOG_LEVEL_WARNING, which doesn't log the location of
the ws_log() call.
2021-06-19 04:37:26 -07:00
João Valverde 0e50979b3f Replace g_assert() with ws_assert() 2021-06-19 01:23:31 +00:00
João Valverde 39df3ae3c0 Replace g_log() calls with ws_log() 2021-06-16 12:50:27 +00:00
Martin Haaß 40e5934444 first version of reassembly btatt
does trigger reassembly but never accumulates data
2021-02-09 05:01:18 +00:00
Guy Harris 20800366dd HTTPS (almost) everywhere.
Change all wireshark.org URLs to use https.

Fix some broken links while we're at it.

Change-Id: I161bf8eeca43b8027605acea666032da86f5ea1c
Reviewed-on: https://code.wireshark.org/review/34089
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-07-26 18:44:40 +00:00
Gerald Combs 8f08a4e74e Try to discourage the use of APIs via counting.
Add the ability to specify maximum function counts for each group to
checkAPIs. Add maximum counts for the "termoutput" and "abort" groups
where needed. Show summaries in various checkAPI targets.

Switch uses of ws_g_warning back to plain g_warning.

Change-Id: I5cbddc8c671729e424eed8551f69116d16491976
Reviewed-on: https://code.wireshark.org/review/29721
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-09-19 16:07:03 +00:00
Guy Harris 6522647d11 Put protocol name before "length of contained item...".
It reads better, at least to me.

Change-Id: I4b11449ea32d77e95bfbc54029b7afed7ea17c64
Reviewed-on: https://code.wireshark.org/review/27081
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-04-22 21:45:48 +00:00
Guy Harris 0a130c5756 Handle subset tvbuffs where the length goes past the end of the parent.
Add a "contained length" to tvbuffs.  For non-subset tvbuffs, that's the
same as the reported length.  For a subset tvbuff, that's the amount of
the reported data that was actually present in the "contained data" of
the parent tvbuff.

This is unaffected by the *captured* length of any tvbuff; that differs
from the contained length only if the capture was cut short by a
snapshot length.

If a reference is within the reported data, but not within the contained
data, a ContainedBoundsError exception is thrown.  This exception
represents a protocol error, rather than a reference past the captured
data in the packet; we treat it as such.

Change-Id: Ide87f81238eaeb89b3093f54a87bf7f715485af5
Reviewed-on: https://code.wireshark.org/review/27039
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-04-20 03:18:47 +00:00
Dario Lombardo 55c68ee69c epan: use SPDX indentifiers.
Skipping dissectors dir for now.

Change-Id: I717b66bfbc7cc81b83f8c2cbc011fcad643796aa
Reviewed-on: https://code.wireshark.org/review/25694
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-08 19:29:45 +00:00
Michael Mann 21a3b8cc71 Internalize struct preference
Move "struct preference" into prefs.c, essentially creating a "private"
structure to handle preferences. The 2 motivating factors were:
1. Better memory management so that clients/users of API don't have to worry
about it.
2. Hide the ugliness of the union stuff and make it transparent to the API.

A few bugs related to preference <-> Decode As integration were fixed
while in the neighborhood.

Change-Id: I509b9a236235d066b139c98222b701475e0ed365
Reviewed-on: https://code.wireshark.org/review/19578
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-01-22 10:43:57 +00:00
Michael Mann 907d49483d Fix some of the checkAPIs.pl warnings for g_warning.
1. Create ws_g_warning for legitimate uses of g_warning
2. Use proto_tree_add_debug_text
3. Comment some out

Change-Id: Ida044bf40286b955fdd529c4f9907c8e09b3d7c5
Reviewed-on: https://code.wireshark.org/review/16678
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-07-26 04:08:50 +00:00
Guy Harris bc5a0374bf Add the packet number to the packet_info structure, and use it.
That removes most of the uses of the frame number field in the
frame_data structure.

Change-Id: Ie22e4533e87f8360d7c0a61ca6ffb796cc233f22
Reviewed-on: https://code.wireshark.org/review/13509
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-01-24 03:41:28 +00:00
Michael Mann 6514dece0c Add preference for disabling 'packet size limited during capture' message in Info column.
Bug: 9827
Change-Id: I8fdba4827b164bd231981bfdd2e1bd0499f4f87c
Reviewed-on: https://code.wireshark.org/review/9669
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-07-17 11:29:08 +00:00
Bill Meier 23e78cd6bd Add editor modelines; Adjust whitespace as needed.
Change-Id: I3dc57f4c2ca57585103e3b71503ac4c332903e50
Reviewed-on: https://code.wireshark.org/review/4594
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-10-10 14:50:08 +00:00
Alexis La Goutte 296591399f Remove all $Id$ from top of file
(Using sed : sed -i '/^ \* \$Id\$/,+1 d')

Fix manually some typo (in export_object_dicom.c and crc16-plain.c)

Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8
Reviewed-on: https://code.wireshark.org/review/497
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-04 14:27:33 +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
Michael Mann 9ccefb0ecd Prefix all "Wireshark application specific" display filters with a "_ws." to distinguish them from dissector filters.
This was committed now to get it into the 1.11 release so users can start getting used to the changed filter names.

svn path=/trunk/; revision=52462
2013-10-09 12:56:19 +00:00
Michael Mann bffe25fdc2 Complete the conversion of expert_add_info_format_text -> expert_add_info_format.
svn path=/trunk/; revision=51853
2013-09-09 01:02:44 +00:00
Michael Mann 15f1dd9b90 Convert malformed ("protocol") expert infos into something filterable. Not sure if "malformed.expert" is more confusing than helpful, but I didn't want it to share with the "malformed" display filter because their underlying types are different (FT_PROTOCOL vs FT_NONE). The ".expert" has been my convention when a condition already has a well-named hf_ display filter, but also has expert info associated with it.
Also removed the commented out calls to expert_add_info_format to avoid confusion, but left the comments noting the reason it's absent.

svn path=/trunk/; revision=51842
2013-09-08 18:35:36 +00:00
Michael Mann e5cb4d84cc proto_malformed SHOULD NOT be used outside of show_exception.c
svn path=/trunk/; revision=50325
2013-07-02 20:43:21 +00:00
Guy Harris 82d2d5a1ec If pinfo->fragmented is set, map ReportedBoundsError to
FragmentBoundsError.

svn path=/trunk/; revision=48946
2013-04-21 06:14:11 +00:00
Guy Harris a0e54160af show_reported_bounds_error() should only be used to handle things such
as overflows in offsets, where the error presumably was that some field
size was so bogusly huge that it overflowed 32 bits; that's a malformed
packet even if the packet wasn't reassembled.

svn path=/trunk/; revision=48945
2013-04-21 03:22:30 +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
Evan Huus b20db86a6f Define a new exception for reassembly errors, and throw it in several cases
instead of using DISSECTOR_ASSERT. When a dissector passes bad data to the
reassembly machine, that isn't necessarily the dissector's fault - the data may
come straight from the packet, and the dissector may not have enough information
to know it's bad without telling the reassembly machine in the first place.

Also fix a bug in the reassembly machine. If it were given a fragment and all of
the following conditions were met:
- the other associated fragments were already marked as done (reassembled)
- the fragment went beyond the end of the conceptual reassembled buffer
- the dissector had not set the PARTIAL_REASSEMBLY flag
then the reassembly machine would incorrectly think there was an overlap and
run past the end of the already-reassembled buffer.

Should fix the rest of
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8380

#BACKPORT
This is probably too big and intrusive to backport directly, and parts of it
will need adapting anyways since reassemble.c has changed. But the bug exists
and crashes in 1.6 and 1.8, so we'll have to do something.


svn path=/trunk/; revision=48011
2013-03-02 16:39:56 +00:00
Guy Harris 6b629c4d92 Move show_exception() and show_reported_bounds_error() to
epan/show_exception.c, as it's used outside
epan/dissectors/packet-frame.c.  Update their callers to include
<epan/show_exception.h> to get their declaration.

Add a CATCH_NONFATAL_ERRORS macro that catches all exceptions that, if
there's more stuff in the packet to dissect after the dissector call
that threw the exception, doesn't mean you shouldn't go ahead and
dissect that stuff.  Use it in all those cases, including ones where
BoundsError was inappropriately being caught (you want those passed up
to the top level, so that the packet is reported as having been cut
short in the capture process).

Add a CATCH_BOUNDS_ERRORS macro that catches all exceptions that
correspond to running past the end of the data for a tvbuff; use it
rather than explicitly catching those exceptions individually, and
rather than just catching all exceptions (the only place that
DissectorError should be caught, for example, is at the top level, so
dissector bugs show up in the protocol tree).

Don't catch and then immediately rethrow exceptions without doing
anything else; just let the exceptions go up to the final catcher.

Use show_exception() to report non-fatal errors, rather than doing it
yourself.
 
If a dissector is called from Lua, catch all non-fatal errors and use
show_exception() to report them rather than catching only
ReportedBoundsError and adding a proto_malformed item.

Don't catch exceptions when constructing a trailer tvbuff in
packet-ieee8023.c - just construct it after the payload has been
dissected, and let whatever exceptions that throws be handled at the top
level.

Avoid some TRY/CATCH/ENDTRY cases by using checks such as
tvb_bytes_exist() before even looking in the tvbuff.

svn path=/trunk/; revision=47924
2013-02-27 22:43:54 +00:00