Guy Harris [Wed, 30 Sep 2020 18:37:30 +0000 (11:37 -0700)]
Handle very large -f files by rejecting them.
_read(), on Windows, has a 32-bit size argument and a 32-bit return
value, so reject -f files that have more than 2^31-1 characters.
Add some #defines so that, on Windows, we use _fstati64 to get the size
of that file, to handle large files.
Don't assume that our definition for ssize_t is the same size as size_t;
by the time we want to print the return value of the read, we know it'll
fit into an int, so just cast it to int and print it with %d.
Add a break at the end of the RSVP_OBJ_LABEL_SET case block as it fully
deals with class number 36 (LABEL_SET) from RFC 3473 Section 2.6 and is
not related to the class in next case block.
Add a break at the end of the RSVP_OBJ_S2L case block as it fully deals
with class number 50 (S2L_SUB_LSP) from RFC 4875 Section 19.3 and does
not need to fall through to the default case block.
Guy Harris [Sat, 18 Apr 2020 21:04:59 +0000 (14:04 -0700)]
PPP: When un-escaping, don't allocate a too-large buffer.
The buffer should be big enough to hold the captured data, but it
doesn't need to be big enough to hold the entire on-the-network packet,
if we haven't captured all of it.
Michael Richardson [Sun, 18 Aug 2019 20:52:56 +0000 (16:52 -0400)]
save stderr to file in case it is useful
do better recording of when stderr has content in it
the failed/passed count was not kept in the right place
and the failure-outputs need to be dumped from the right place
record status code better to file, and if it exists, compare the stderr as well
sanitizing the first line for filename path
Denis Ovsienko [Tue, 28 Aug 2018 23:38:40 +0000 (00:38 +0100)]
(for 4.9.3) CVE-2018-16227/IEEE 802.11: add a missing bounds check
ieee802_11_print() tried to access the Mesh Flags subfield of the Mesh
Control field to find the size of the latter and increment the expected
802.11 header length before checking it is fully present in the input
buffer. Add an intermediate bounds check to make it safe.
This fixes a buffer over-read discovered by Ryan Ackroyd.
Add a test using the capture file supplied by the reporter(s).
Denis Ovsienko [Thu, 23 Aug 2018 22:32:07 +0000 (23:32 +0100)]
(for 4.9.3) CVE-2018-16228/HNCP: make buffer access safer
print_prefix() has a buffer and does not initialize it. It may call
decode_prefix6(), which also does not initialize the buffer on invalid
input. When that happens, make sure to return from print_prefix() before
trying to print the [still uninitialized] buffer.
This fixes a buffer over-read discovered by Wang Junjie of 360 ESG
Codesafe Team.
Add a test using the capture file supplied by the reporter(s).
Denis Ovsienko [Thu, 23 Aug 2018 21:09:16 +0000 (22:09 +0100)]
(for 4.9.3) CVE-2018-16230/BGP: fix decoding of MP_REACH_NLRI
When bgp_attr_print() tried to decode the variable-length nexthop value
for the NSAP VPN case, it did not check that the declared length is good
to interpret the value as a mapped IPv4 or IPv6 address. Add missing
checks to make this safe.
This fixes a buffer over-read discovered by Include Security working
under the Mozilla SOS program in 2018 by means of code audit.
Bhargava Shastry, SecT/TU Berlin, had independently identified this
vulnerability by means of fuzzing and provided the packet capture file
for the test.
The only function tcpdump used in libdnet was dnet_htoa(), which tries
to translate a binary DECnet address to a nodename through a lookup in
/etc/decnet.conf. The translation is slow and has a bug, so stop using
the function and remove the dependency on libdnet.
This makes tcpdump always print DECnet addresses in numeric format, if
anybody needs the translation back they are welcome to fix libdnet or
(more realistically) add an implementation of dnet_htoa() to the tcpdump
source code and use it.
Denis Ovsienko [Sun, 17 Jun 2018 21:15:19 +0000 (22:15 +0100)]
(for 4.9.3) CVE-2018-14879/fix -V to fail invalid input safely
get_next_file() did not check the return value of strlen() and
underflowed an array index if the line read by fgets() from the file
started with \0. This caused an out-of-bounds read and could cause a
write. Add the missing check.
This vulnerability was discovered by Brian Carpenter & Geeknik Labs.
Francois-Xavier Le Bail [Fri, 3 Nov 2017 15:32:30 +0000 (16:32 +0100)]
(for 4.9.3) CVE-2018-14882/ICMP6 RPL: Add a missing bounds check
Moreover:
Add and use *_tstr[] strings.
Update four tests outputs accordingly.
Fix a space.
Wang Junjie of 360 ESG Codesafe Team had independently identified this
vulnerability in 2018 by means of fuzzing and provided the packet capture
file for the test.
Francois-Xavier Le Bail [Sat, 4 Nov 2017 15:06:33 +0000 (16:06 +0100)]
(for 4.9.3) CVE-2018-14880/OSPFv3: Fix a bounds check
Need to test bounds check for the last field of the structure lsa6_hdr.
No need to test other fields.
Include Security working under the Mozilla SOS program had independently
identified this vulnerability in 2018 by means of code audit.
Wang Junjie of 360 ESG Codesafe Team had independently identified this
vulnerability in 2018 by means of fuzzing and provided the packet capture
file for the test.
(for 4.9.3) CVE-2018-14466/Rx: fix an over-read bug
In rx_cache_insert() and rx_cache_find() properly read the serviceId
field of the rx_header structure as a 16-bit integer. When those
functions tried to read 32 bits the extra 16 bits could be outside of
the bounds checked in rx_print() for the rx_header structure, as
serviceId is the last field in that structure.
This fixes a buffer over-read discovered by Bhargava Shastry,
SecT/TU Berlin.
Add a test using the capture file supplied by the reporter(s).
At the beginning of mfr_print() check the declared length too, not just
the size of the input buffer. This should make further length-based
decoding more correct.
Found by code inspection hence there is no test case at this time.
In babel_print_v2() check that the Babel packet body length does not
exceed the outer UDP packet payload. This helps to detect some invalid
packets earlier but does not fix a known vulnerability.
(for 4.9.3) CVE-2018-14468/FRF.16: Add a missing length check.
The specification says in a well-formed Magic Number information element
the data is exactly 4 bytes long. In mfr_print() check this before trying
to read those 4 bytes.
This fixes a buffer over-read discovered by Bhargava Shastry,
SecT/TU Berlin.
Add a test using the capture file supplied by the reporter(s).