Denis Ovsienko [Fri, 11 Mar 2022 15:07:08 +0000 (15:07 +0000)]
CI: Relax the illumos exemption rule. [skip appveyor]
As it turns out, the same warnings reproduce with other Clang versions
(at least 11) and other illumos distributions (at least OmniOS), so omit
Clang version in the pattern.
Francois-Xavier Le Bail [Tue, 8 Mar 2022 09:28:35 +0000 (10:28 +0100)]
Fix two invalid tests
Fix these cppcheck warnings:
addrtoname.c:1288:11: warning: Checking if unsigned expression 'num'
is less than zero. [unsignedLessThanZero]
if (num <= 0) {
^
addrtoname.c:1308:11: warning: Checking if unsigned expression 'num'
is less than zero. [unsignedLessThanZero]
if (num <= 0) {
^
Guy Harris [Sat, 5 Mar 2022 00:01:01 +0000 (16:01 -0800)]
Clean a bunch of fuzzed files not to fuzz the container.
For some reason pcap fuzzers just *love* to fuzz the "link-layer type
plus other stuff" part of the pcap file header. That can produce a file
that has non-zero values in reserved fields, which means it can get
rejected well before being handed to anything for dissection.
Clear out one of the reserved parts of that field, as we'll be changing
libpcap to check for non-zero values and reporting an error.
Francois-Xavier Le Bail [Wed, 2 Mar 2022 20:48:43 +0000 (21:48 +0100)]
RESP: Fix an invalid check
Fix this cppcheck warning:
print-resp.c:215:22: warning: Checking if unsigned expression 'length'
is less than zero. [unsignedLessThanZero]
if(!bp || length <= 0)
^
Francois-Xavier Le Bail [Wed, 2 Mar 2022 16:46:27 +0000 (17:46 +0100)]
TCP: Fix an invalid check
Fix this cppcheck warning:
print-tcp.c:711:20: warning: Checking if unsigned expression 'length'
is less than zero. [unsignedLessThanZero]
if (length <= 0)
^
Francois-Xavier Le Bail [Mon, 7 Feb 2022 14:51:36 +0000 (15:51 +0100)]
ICMP: Fix printing the Interface Name Sub-Object
RFC 5837 - 4.3. Interface Name Sub-Object
"The Interface Name Sub-Object MUST have a length that is a multiple
of 4 octets and MUST NOT exceed 64 octets.
The Length field represents the length of the Interface Name Sub-
Object, including the length and the interface name in octets."
The length of the interface name to print is: (Length field) - 1.
The offset is only: Length field
Add sanity checks: Multiple of 4 octets, <= 64 octets.
Fix the icmp-rfc5837.pcap test.
The interface name length in octets is 63, thus the length field must be 64.
Update also the ICMP Multi-Part Extensions checksum.
Keep an invalid length field in icmp-cksum-oobr-2.pcap.
Denis Ovsienko [Mon, 7 Feb 2022 12:36:46 +0000 (12:36 +0000)]
Add CVE-2018-16301 to CHANGES. [skip ci]
One of the effects of commit faf8fb7 was fixing a buffer overflow that
was discovered and reported by Include Security (case reference "F2").
Their work was sponsored by Mozilla under the Secure Open Source
program. The vulnerability was assigned CVE-2018-16301 on 2018-09-01
(MITRE request reference "scr562827"), but was not properly documented
afterwards. Add a line to the change log section for 4.99.0, which at
the time of this writing is the first release to incorporate the fix.
See also https://github.com/the-tcpdump-group/libpcap/issues/855
Guy Harris [Sun, 30 Jan 2022 08:00:33 +0000 (00:00 -0800)]
Run the test that fails on OpenBSD only if we're not on OpenBSD.
Don't test whether we have net/if_pflog.h, test whether we're on
OpenBSD; we no longer check for net/if_pflog.h in the configure script,
and that's not a valid "is this OpenBSD?" check in any case, as other
*BSDs have it as well.
Guy Harris [Sun, 30 Jan 2022 06:30:33 +0000 (22:30 -0800)]
Handle DLT_PFLOG on all OSes.
Don't pad the pflog header with BPF_WORDALIGN(); round up to a multiple
of 4, instead, as that's what all but FreeBSD do, and FreeBSD used to do
that and should go back to doing so (kern/261566).
Don't rely on the OS's pflog include files to define direction types,
reason types, action types, or the layout of the header; instead, define
them ourselves in a header of our own, with #ifs to select the ones that
are only on some platforms. That way, it'll handle some fields and
field values (the ones common to all OSes with pflog) on all OSes, even
ones without pflog.
That also expands the set of direction, reason, and action codes to what
various *BSDs and Darwin support.
Also, handle all the different AF_INET6 values in various *BSDs and
Darwin.
Guy Harris [Wed, 26 Jan 2022 07:43:57 +0000 (23:43 -0800)]
realtek: redo the checks for different protocols.
Do it iwth an if chain, which is somewhat the equivalent of what
Wireshark does (it uses heuristic dissectors; our ifs do the same checks
that Wireshark's heuristic dissectors do).
That makes it a bit more obvious that the necessary tests are somewhat
weird, thanks to Realtek not just deciding to make the first octet a
protocol discriminator *even for switch tags*.
We also treat a first octet of 0x23 as meanin RLDP, just as Wireshark
does, as some switch chips use 0x23 for loop detection packets.
Shuffle some comments while we're at it (and epand the one for RLDP to
match all the stuff going on with various RLDP packets).
Guy Harris [Sun, 23 Jan 2022 09:44:16 +0000 (01:44 -0800)]
Support more Realtek protocols than RRCP.
The Ethertype 0x8899 is used by Realtek for several over-the-wire
protocols, as well as for supplying tag information to a host CPU from a
Realtek chip. Add code to handle protocols other than RRCP, although we
don't fully dissect all of them.
Francois-Xavier Le Bail [Mon, 10 Jan 2022 15:37:07 +0000 (16:37 +0100)]
autoconf: Add the option to print functions names (entry and exit)
This should help some debugging processes.
Usage:
./configure --enable-instrument-functions
Generate instrumentation calls for entry and exit to functions.
Just after function entry and just before function exit, these
profiling functions are called and print the function names with
indentation and call level.
To instument a static function, remove temporarily the static specifier.
In case of truncation, the indentation level is reset currently to 1 in
pretty_print_packet(), main is level 0.
Nathan O'Sullivan [Mon, 17 Jan 2022 00:05:15 +0000 (10:05 +1000)]
Add --print-sampling option to print every Nth packet
New option `--print-sampling=NTH` will parse and print every NTH packet,
with all other packets producing no output. This option enables
`--print` and `-S` flags.
Print sampling is useful for real-time inspection of an interface with
a high packet rate, or initial inspection of large capture files.
Francois-Xavier Le Bail [Sat, 1 Jan 2022 11:40:59 +0000 (12:40 +0100)]
DCCP: Modernize packet parsing
Enable ND_LONGJMP_FROM_TCHECK.
Use ND_ICHECK*() for length checks.
Fix some length checks.
Add and use standard "invalid" sections.
Remove the redundant ND_TCHECK*() instances.
Add a ND_TCHECK_1().
Factorize some codes.
Update default format for tok2str() calls.
Indicate better invalid packet types, invalid option types,
invalid reset codes and invalid features.
Fix process for DCCP_OPTION_CHANGE_L/DCCP_OPTION_CHANGE_R, not the
same that DCCP_OPTION_CONFIRM_L/DCCP_OPTION_CONFIRM_R process.
Remove spaces in some dccp_feature_num_str[] strings.
Update the output of a test accordingly.
Guy Harris [Thu, 6 Jan 2022 23:05:07 +0000 (15:05 -0800)]
appveyor CI: update Npcap site, update to 1.12 SDK
As per the comments on https://github.com/nmap/npcap/issues/576, we
should go to npcap.com for Npcap-related stuff.
Denis Ovsienko [Wed, 5 Jan 2022 22:57:45 +0000 (22:57 +0000)]
OpenFlow: Refine more length checks.
In print-openflow-1.0.c and print-openflow-1.3.c replace the remaining
"goto invalid" checks with ND_ICHECK_U() and ND_ICHECKMSG_U(). Redo the
changes from commit 1ce16ea: use the same order of arguments and the
same comparison operators as before the change and lose the unsigned
compensation, which is no longer required. Add another test case using
a malformed packet from Francois-Xavier.
Denis Ovsienko [Tue, 4 Jan 2022 21:53:00 +0000 (21:53 +0000)]
Use unified diff by default. [skip ci]
GNU/Linux (specifically, the GNU part), FreeBSD, NetBSD, OpenBSD,
illumos and even Solaris 9 and AIX 7.1 all have a diff that supports
"-u" for unified output format. Let that be the default to make test
failures more intelligible for humans. The old behaviour is available
with "DIFF_FLAGS= make check".
Denis Ovsienko [Wed, 29 Dec 2021 21:06:25 +0000 (21:06 +0000)]
OpenFlow 1.0: Improve handling of some lengths.
For OFPT_PACKET_OUT print "actions_len", as it is a part of the message
and should appear in its decoding (in other message types it is derived
from the message length).
ND_ICHECK_*() in of10_actions_print(), of10_flow_stats_reply_print() and
of10_packet_out_print() after printing at least some of the output.
This, compared to just "(invalid) (invalid)", makes it much easier to
understand where and why the packet data was not fully decoded. Define
OF_ACTION_MINLEN unsigned to squelch the induced compiler warnings. A
number of similar checks still remain to be converted the same way.
Francois-Xavier Le Bail [Wed, 29 Dec 2021 13:38:08 +0000 (14:38 +0100)]
Update the ND_LCHECK*() macros to ND_ICHECK*() macros
ICHECK like Invalid-Check.
Reminder: If the checked expression is true an error message is printed
and a 'goto invalid' is executed.
This change adds the parameter 'operator'.
Before this change, '<' comparison was hard coded.
We can do now:
ND_ICHECK_U(length, <, HEADER_LEN);
ND_ICHECK_U(length, ==, 24);
ND_ICHECK_U(length, !=, 8);
ND_ICHECK_ZU(length, <, sizeof(struct my_struct));
ND_ICHECKMSG_U("message length", msg_tlen, <, 4);
...
(Any comparison operator)
Remark: The change of names from ND_LCHECK*() to ND_ICHECK*() is
because something else than a length(L) can be checked.
Moreover:
Place the 'message' parameter at the beginning of ND_ICHECKMSG_U()
and ND_ICHECKMSG_ZU() paramaters lists.