This is a follow-up to commit e606750 (RFC 3162).
Move the bounds check before the code that reads from the input buffer,
make the IPv6 address temporary buffer right-sized, add a test and a
diagnostic message for the prefix length.
NAS IPv6 Address (95)
Framed Interface ID (96)
Framed IPv6 Prefix (97)
Login IPv6 Host (98)
Framed IPv6 Route (99)
Framed IPv6 Pool (100)
Added new functions to print ipv6 address and netmask, added unit test to test those.
Use strtol() to get the size, as it's a long.
Make sure the argument is > 0; negative values, and 0, are invalid.
Make sure it won't overflow a long when it's multiplied by 1000000.
Note in a comment that this doesn't yet handle those arguments if they
can't fit into a long; that would require a new API in libpcap.
This should fix GitHub issue #488, at least on platforms where a long is
large enough (64-bit UN*Xes) and where files > 2^31 GB are supported.
The seconds value in a 64-bit NTP timestamp is unsigned. Treat it as
such.
When converting it to a UN*X seconds-since-the-Epoch, cast the 32-bit
seconds value from an NTP timestap to a 64-bit signed value (which is
always possible), and then subtract the signed delta between 1900 and
1970, giving a signed seconds-since-the-Epoch value.
Then assign that to a time_t; if that variable doesn't have the same
value as the calculated 64-bit value, we can't represent it in a time_t,
so just report it as unrepresentable.
Otherwise, use that resulting value in a gmtime() call - and make sure
gmtime() doesn't return NULL, which it can do with some versions of the
Microsoft C runtime. If it does, report the time as unrepresentable,
otherwise report it as YYYY-MM-DDTHH:MM:SS.
This fixes the 32-bit vs. 64-bit issue for tests.
It also changes the test output, so update that.
The default *grep in Solaris is *NOT* SUSv3-compliant, and doesn't
support -q; you have to use the one in /usr/xpg4/bin for that one.
Just use egrep (to make sure we support alternation, which we use),
don't pass it -q, and send its output to /dev/null, as we don't need to
see it.
If there's a performance difference between them, it probably won't make
a difference here, and the Single UNIX Specification does include grep,
and says it has to support -q, but doesn't mention egrep. See if this
eliminates a complaint from the OpenCSW buildbot.
A 32-bit tcpdump probably has a signed 32-bit time_t (it might not, on,
for example, newer versions of NetBSD). Some time stamps in ntp.pcap
fall after the Y2.038K deadline, and get misreported if they don't fit
in 31 bits (the topmost bit is a sign bit).
In ntp_time_print() do not print the information already printed in
ntp_print(): mode, leap indicator, version (all part of the Status
header field) and length. Update the test case.
See if this fixes the crashes on the OpenCSW SPARC buildbots. If so, it
means that the compiler may think that even structures made up of
nothing but bytes (char/unsigned char) and arrays of bytes are aligned,
even if there's no guarantee of that.
(Bad compiler! No biscuit!)
[print-icmp.c:402]: (warning) %d in format string (no. 2) requires 'int'
but the argument type is 'unsigned int'.
[print-icmp.c:560]: (style) The scope of the variable 'sum' can be
reduced.
[print-icmp.c:560]: (style) The scope of the variable 'icmp_sum' can be
reduced.
[print-icmp.c:509]: (warning) %d in format string (no. 1) requires 'int'
but the argument type is 'unsigned int'.
[print-icmp.c:517]: (warning) %d in format string (no. 1) requires 'int'
but the argument type is 'unsigned int'.
draft-ietf-isis-traffic-05 became RFC 3784 (Informational), which was
later republished as RFC 5305 (Standards Track). As far as I could tell
from the diffs, the changes between those documents do not require
changes to the decoder (which does not cover 100% of the specification,
but that is another story).
This does not fix a known bug but prevents a possible bug in future
because without the parentheses an expression like "2 * NODE_ID_LEN"
looks differently from how it actually works. Drop some unnecessary
parentheses in the source code.
If we have a libpcap with <pcap/pcap-inttypes.h>, include it, so that we
don't have to worry about definitions colliding if we later include a
pcap header file that includes pcap/pcap-inttypes.h.
Otherwise, do the same stuff pcap-inttypes.h does. This means that, on
UN*X, we require that there be an <inttypes.h> that defines everything
we need.
Don't bother doing checks that are no longer necessary as a result of
those changes.
Fetch the values from the files at the end of runComplexTests, rather
than at the beginning of runSimpleTests - they're already set to 0 if
you haven't run runComplexTests.
Set the variables to 0 right before writing their values to the files,
just to make it clearer that they're both being initialized to 0.
Read the files unconditionally in tests/crypto.sh, as we do tests
regardless of whether we were built with libcrypto or not.
The EIGRP protocol can be carried in IPv4 or IPv6. The basic protocol
remains the same. So call the EIGRP dissector for IPv6 packets with
IPPROTO_EIGRP.
Use a pointer of the correct type in ND_TCHECK(), or use ND_TCHECK2()
and provide the correct length.
While we're at it, remove the blank line between some checks and the
UNALIGNED_MEMCPY()s they protect.
Also, note the places where we print the entire payload.
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).
An IPv6 address plus subnet mask is 32 bytes, not 20 bytes.
16 bytes of IPv6 address, 16 bytes of subnet mask.
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).