Commit Graph

4426 Commits

Author SHA1 Message Date
Guy Harris
0cb34b7b44 Just handle COUNTER64 as a u_int64.
No need to worry about 64-bit integers any more - we require compiler
and printf support for them.
2017-01-18 09:16:40 +01:00
Guy Harris
e4371fa1e8 More bounds and length checks.
Catch INTEGER values with a length of 0, so we don't fetch a byte that
doesn't belong to the value.

Fix what appears to be a long-standing bug in the OID prefix matching
code, wherein the length of the *first* prefix in the table is used as
the length of *all* prefixes, and add some packet-length checking to
that list.

Report packets with an invalid SNMP version number as being SNMP, so
we at least indicate *that*.
2017-01-18 09:16:40 +01:00
Guy Harris
3b841a3852 Update the test results.
The output is different with some recent changes.
2017-01-18 09:16:40 +01:00
Guy Harris
42d07777ee Fix bounds checks.
At the beginning, make sure the on-the-wire length is >= the size of the
EGP header, and make sure the captured data is >= the size of the EGP
header, rather than making sure we have all the captured data, as we're
only looking at the header there.

Do on-the-wire length checking in egpnrprint().
2017-01-18 09:16:40 +01:00
Guy Harris
2e102855d0 Redo TLV bounds checking.
If the L of the V of the TLV isn't large enough for everything it's
supposed to contain, just quit processing the TLV, print its contents in
hex, and process the next TLV.
2017-01-18 09:16:40 +01:00
Guy Harris
88e975d68f Make sure the Opaque_Handle string is null-terminated.
...even if the file handle length is 0.
2017-01-18 09:16:40 +01:00
Guy Harris
b4e5a87bc4 Fixes to match the IEEE standard, and additional bounds and length checks.
Fix a lot of the dissection to match what 802.1ag-2007 says.

Add a bunch of bounds and length checks.
2017-01-18 09:16:40 +01:00
Guy Harris
c6415c9854 Fix bugs, add checks.
Add multiple bounds and length checks to make sure we don't run past the
end of the packet.

Don't check the length of "end of TLV" indicators; 802.3 says it should
be ignored.

The Event Notification OAMPDU has a sequence number; report it.
2017-01-18 09:16:40 +01:00
Guy Harris
6643795d12 Updates for RFC 4379, bug fixes, and additional bounds checks.
print-lspping.c was written to one of the draft-ietf-mpls-lsp-ping-13
drafts; incorporate subsequent changes that are in RFC 4379.  Not all
LV and subTLV types from that RFC are currently dissected.

Apparently, the IANA has two separate but similar registries, the BGP
Layer 2 Encapsulation Types registry and the MPLS Pseudowire Types
registry.  Have two separate tables for them, and use the tables as
appropriate.  Update them to match the current state of the registries.

11 is not the subTLV code for "BGP labeled IPv4 prefix" (and never was,
from what I can tell from looking at the I-Ds), 12 is.

Do more bounds checking.
2017-01-18 09:16:40 +01:00
Francois-Xavier Le Bail
79d80f09f3 SNMP: Add some bounds checks 2017-01-18 09:16:40 +01:00
Guy Harris
ec9d847037 Add a bounds check.
The bounds check for the Hello packet options was missing.
2017-01-18 09:16:40 +01:00
Guy Harris
ecf6e822e1 Do bounds checks on NBNS resource types and resource data lengths. 2017-01-18 09:16:40 +01:00
Guy Harris
df60a6c956 Fix some if statements missing brackets. 2017-01-18 09:16:40 +01:00
Guy Harris
97d372ef70 Before fetching the flags2 field, make sure we have it.
Also, don't fetch it until we need it, so we can do a little more
dissection before reporting a truncated packet.
2017-01-18 09:16:40 +01:00
Guy Harris
9f8c1a7492 Do bounds checks when printing character and octet strings.
Pull the code in asn1_print() to print octet sequences and (presumed)
printable strings into routines of their own, and use them when we're
printing them outside asn1_print().

That fixes some cases where we can run past the end of the packet
buffer.
2017-01-18 09:16:40 +01:00
Francois-Xavier Le Bail
c37100fd4c Add a test file for a previous fix
Fix was: "Don't overflow the Opaque_Handle buffer."
2017-01-18 09:16:40 +01:00
Guy Harris
91161b828f Do length checking for the key ID of the enhanced auth option. 2017-01-18 09:16:40 +01:00
Guy Harris
ea6ddc5e71 Don't overflow the Opaque_Handle buffer.
The file handle length can be arbitrarily large; don't assume its hex
dump will fit in the buffer, just truncate it if it doesn't.
2017-01-18 09:16:39 +01:00
Guy Harris
ed0237af69 Adjust for fix to TCP option printout. 2017-01-18 09:16:39 +01:00
Guy Harris
65202da9dc Don't run past the end of an NFSv3 file handle.
NFSv2 file handles are always 32 bytes long, possibly with zero padding
at the end.

NFSv3 file handles are variable-length, however, so we cannot assume
that they have any minimum number of bytes of data; check that bytes
are present before looking at them.
2017-01-18 09:16:39 +01:00
Guy Harris
ce9bc5af51 Tests for Frame Relay problems.
The problems were found by Hanno Böck with American Fuzzy Lop.
2017-01-18 09:16:39 +01:00
Francois-Xavier Le Bail
beca6e7025 IGMP: Add a length check 2017-01-18 09:16:39 +01:00
Francois-Xavier Le Bail
9281ad283a Fix indentation in "make check" output 2017-01-18 09:16:39 +01:00
Francois-Xavier Le Bail
81c7798d00 ISOCLNS: Manage a test as GCC-specific 2017-01-18 09:16:39 +01:00
Francois-Xavier Le Bail
56844d158c Update a test output for a previous fix
Fix was: "RSVP: Add bounds and length checks"
(commit 2bdecbfb10)
2017-01-18 09:16:39 +01:00
Guy Harris
5f1caad633 Consistently use 4, rather than a sizeof, as the size of an IPv4 address. 2017-01-18 09:16:39 +01:00
Francois-Xavier Le Bail
266489c6c9 Add a test file for a previous fix
Fix was: "OSPF: Fix a segmentation fault"
(commit 046f10da38)
2017-01-18 09:16:39 +01:00
Francois-Xavier Le Bail
b3c215000f Add a test file for a previous fix
Fix was: "UDLD: Fix an infinite loop"
(commit 9759a5bc71)
2017-01-18 09:16:39 +01:00
Francois-Xavier Le Bail
cb922d07cc CVE-2016-7934,7935,7937/RTP: Fix two segmentation faults
Add two test files for these fixes.
Add more bounds checks in VAT, RTP and RTCP printers.

Moreover:
Add and use *_tstr[] strings.
Update the output of a test accordingly.
Remove spaces before tabs.
2017-01-18 09:16:39 +01:00
Francois-Xavier Le Bail
3cb7e03825 CVE-2016-7922/AH: Add a bounds check
Moreover:
Fix a warning (unused variable 'ep').
2017-01-18 09:16:39 +01:00
Francois-Xavier Le Bail
8343c39e2f Add a test file for the previous fix 2017-01-18 09:16:39 +01:00
Denis Ovsienko
5a8f78fef0 CVE-2016-7938/ZeroMQ: fix an infinite loop
This issue was discovered through fuzzing by Francois-Xavier Le Bail.
2017-01-18 09:16:39 +01:00
Francois-Xavier Le Bail
8d8f0953cd STP: Remove trailing spaces in output 2017-01-18 09:16:39 +01:00
Francois-Xavier Le Bail
5cb03afb57 STP: Filter out non-printable characters
Use fn_printzp().

Moreover:
Add a missing comma in output.
Use ND_TCHECK_32BITS instead of ND_TTEST_32BITS.
Add a test for spb_bpduv4.pcap with verbose output.
2017-01-18 09:16:38 +01:00
Francois-Xavier Le Bail
51557701bf Add a test file for a previous fix
Fix was: "ISOCLNS: Fix a segmentation fault"
(commit be8e9c9dea)
2017-01-18 09:16:38 +01:00
Francois-Xavier Le Bail
54c0c24b22 Add test files for a previous fix
Fix was: "ISOCLNS: Fix two segmentation faults"
(commit 8db57a4b90)

Moreover:
group together IS-IS tests.
Fix typos.
2017-01-18 09:16:38 +01:00
Francois-Xavier Le Bail
9ad34901e9 Fix the interface capture length of some fuzzed pcap files
They will be always usable with the new interface capture length sanity
check.
(old length: 808464432, new length: 262144)
2017-01-18 09:16:38 +01:00
Francois-Xavier Le Bail
75f84b8eec Fix the file capture length of a fuzzed pcap file
It will be always usable with the new file capture length sanity check.
(old length: 808464432, new length: 262144)
2017-01-18 09:16:38 +01:00
Francois-Xavier Le Bail
3fea8eb0be Add test file for a previous fix
Fix was: "RSVP: Fix an infinite loop"
(commit d7d269e8c6)
2017-01-18 09:16:38 +01:00
Francois-Xavier Le Bail
29d28b1a3f Fix the pcap version in some tests/ fuzzed pcap files
They will be always usable with the upcoming libpcap versions sanity checks.
pcap: old version: 12336.12336, new version: 2.4
pcap-ng: old version: 1.12336, new version: 1.0
2017-01-18 09:16:38 +01:00
Francois-Xavier Le Bail
1e28562171 Fix a trailing tab 2017-01-18 09:16:38 +01:00
Guy Harris
4e85180c53 Clean up signed_relts_print() some more.
If it's not < 0, it's not -2147483648; check for negative values first.

Don't calculate the value for -2147483648 by hand, print a - and then
have unsigned_relts_print() calculate the value for 2147483648.
2017-01-18 09:16:38 +01:00
Guy Harris
3de59bdfa2 Get rid of some duplicated code.
Have signed_relts_print() just call unsigned_relts_print() to do the
formatting, once it's ensured that the value is positive and printed a
leading minus sign if necessary.
2017-01-18 09:16:38 +01:00
Guy Harris
07a361befe Tests for the relts changes. 2017-01-18 09:16:38 +01:00
Guy Harris
d07e352f5a CVE-2016-7993/Clean up relative time stamp printing.
Have separate routines for signed and unsigned relative time stamps.
Have the routine for signed time stamps handle the case of -2^31, where
you can't negate it and have the result fit in a 32-bit signed integer.

There are currently no users of the signed relative time stamp routine,
but it's there in case anybody needs it (and is passing 32-bit
quantitites, so that there's a risk that a packet might contain -2^31 as
the time stamp).

Fixes an array overflow found with American Fuzzy Lop by Hanno Böck.
2017-01-18 09:16:38 +01:00
Guy Harris
7bf069c251 CVE-2016-7983,7984/Don't use strchr() to scan packet data.
It can't be told to stop at the end of the packet data.  Add a
fn_printztn() that prints null-terminated strings, with a length check,
and which returns the number of bytes processed, or 0 if we ran out of
data.  That means it does the scanning we need, but safely.

Use it in the TFTP and BOOTP printers.

Fixes a heap overflow found with American Fuzzy Lop by Hanno Böck.
2017-01-18 09:16:37 +01:00
Guy Harris
5e48a55754 CVE-2016-7929/Make sure a Juniper header TLV isn't bigger than what's left in the packet.
Fixes a heap overflow found with American Fuzzy Lop by Hanno Böck.
2017-01-18 09:16:37 +01:00
Guy Harris
64f6392084 CVE-2016-7923/Don't assume the target hardware address is <= 6 octets long.
It might not be, either because an unusual hardware type is using ARP or
because a maliciously-constructed packet was sent.  Instead of comparing
against a 6-octet string of zeros with memcmp(), check each octet of the
address against 0.

Fixes a heap overflow found with American Fuzzy Lop by Hanno Böck.
2017-01-18 09:16:37 +01:00
Guy Harris
968776fbf5 CVE-2016-7940/Add a bunch of bounds checks, and fix some printing.
The bounds checks fix some heap overflows found with American Fuzzy Lop
by Hanno Böck.

Add some ND_TTEST_/ND_TCHECK_ macros to extract.h to simplify writing
bounds checks for code that uses the other macros in that file.

Fix the printing of the SPB BPDU agreement digest - I don't think the
intent was to print the value of the first 4 bytes, that value + 4, that
value + 8, etc., I suspect it was to print the first 4 bytes, the next 4
bytes, etc..
2017-01-18 09:16:37 +01:00
Guy Harris
b13ef341f7 Check against the packet length first.
That way, if the packet is inherently too short, rather than just having
been cut short by the snapshot length, we'll report that properly.
2017-01-18 09:16:37 +01:00