This catches direct references, so we can change them to use EXTRACT_U_1
or EXTRACT_S_1.
Also, change some structures to use the nd_ types that weren't already
using them.
Then make the appropriate EXTRACT_{U,S}_1() changes.
Now all the macros have a name meaning a count in bytes.
With _S_: signed, _U_: unsigned
e.g.:
EXTRACT_BE_32BITS -> EXTRACT_BE_U_4
EXTRACT_LE_32BITS -> EXTRACT_LE_U_4
...
EXTRACT_BE_INT32 -> EXTRACT_BE_S_4
and have:
EXTRACT_8BITS -> EXTRACT_U_1
EXTRACT_INT8 -> EXTRACT_S_1
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), modified
so the capture file won't be rejected as an invalid capture.
When compiled with the Solaris Studio 12.3 compiler (as in the OpenCSW
buildbot system at the time), tcpdump passed all the tests. When
compiled with GCC 5.2.0 on the same host, the following tests failed
because tcpdump terminated with SIGILL (Bus Error - core dumped):
icmpv6, icmpv6_opt24-v, dhcpv6-aftr-name, dhcpv6-ia-na, dhcpv6-ia-pd,
dhcpv6-ia-ta, dhcpv6-ntp-server, dhcpv6-sip-server-d,
dhcpv6-domain-list, kday1. This change fixes the issue with the method
suggested in commit 1376682.
with the tag '\summary:' for greping.
Remark: Currently some printers have no summary line.
Moreover:
Summarize all printers with a single line in INSTALL.txt
If we have a routing header, instead of overwriting the packet's IPv6
destination address in the packet with the final destination, so that
the next protocol's checksum routine can use it, we do as we do for
IPv4, and, in the "next protocol checksum" routine, scan the headers
looking for a routing header and, if we find one, copy the final
destination from it.
While we're at it, clean up a few things.
Have our own routines to convert between IPv4/IPv6 addresses and
strings; that helps if, for example, we want to build binary versions of
tcpdump for Windows that can run both on NT 5 (W2K/WXP), which doesn't
have inet_ntop() or inet_pton(), and NT 6 (Vista/7/8/10), which do. It
also means that we don't require IPv6 library support on UN*X to print
addresses (if somebody wants to build tcpdump for older UN*Xes lacking
IPv6 support in the system library or in add-on libraries).
Get rid of files in the missing directory that we don't need, and
various no-longer-necessary autoconf tests.
*Don't* fetch it with a pointer cast and dereference! That will fail on
little-endian machines and may fail on machines that don't handle
unaligned references.
The purpose of this macro was to enable the file-by-file switch to NDO,
after which only tcpdump.c had a use of it and the definitions guarded
by it. Update tcpdump.c not to require them any more and dismiss the
unused definitions.
Allow an extra byte in the buffer for snprintf()'s null character,
otherwise it does not work as intended (issue spotted by Gisle Vanem on
Windows, where snprintf() behaviour seems to be different). Update the
tests.
And, as we require at least autoconf 2.61, and as autoconf 2.61 and
later have AC_TYPE_UINTn_T and AC_TYPE_INTn_T macros, we use them to
define the uintN_t and intN_t macros if the system doesn't define them
for us.
This lets us get rid of bitypes.h as well.
Have them take a netdissect_options * argument, and get the "no name
resolution" flag from it.
Move the declaration of dnaddr_string to addrtoname.h, along with the
other XXX-to-string routines.
Eliminate a number of fputs(), putchar() and fflush() uses. Justify
preprocessor directives. Don't typecast ND_PRINT() to void and fix some
indentation.
Get rid of zero-length arrays; not all compilers support them.
Get rid of __attribute__((packed)); not all compilers support it, so we
can't depend on it.
Use explicit constants for sizes, just in case some compilers pad
structures.
Add some length checks.
Make some ND_TTEST2 calls ND_TCHECK2 calls instead, so they report
truncation if they fail.
Constify some pointers.
Remove lots of $Header's and a few $Id's that all belong to the former
CVS repository of tcpdump itself. These keywords have been frozen since
the migration to git in late 2008.
print-ascii.c needs prototypes of ascii_print(),
hex_and_ascii_print_with_offset() and hex_and_ascii_print().
print-icmp6.c needs prototypes of in_cksum_shouldbe() and ns_nprint().
For headers included in only one source file, put the header contents in
the source file in question, and get rid of a bunch of stuff from the
header not used in the source file.
Make sure all of them are declared const and most of them -- static.
Proper declaration of token arrays is a common review point for new code
that is based on existing decoders. Thus fix the issue at its root.
icmp6_opt_print() in the case of ND_OPT_PREFIX_INFORMATION always
appended "s" (seconds) to the returned string result of get_lifetime(),
which could be either a printed number or the "infinite" word. This
change leaves it up to get_lifetime() to decide if "s" is necessary.
This also improves the ND_OPT_ROUTE_INFO case, where route information
lifetime has the same type and semantics.
The most notable difference between RFC5006 and RFC6106 is the addition
of DNSSL RA option. This commit adds DNSSL handling code to make tcpdump
fully RFC6106-aware. This code has been tested against RA packets
generated by Quagga and radvd.
RFC 6275 7.3. New Advertisement Interval Option Format
Advertisement Interval
32-bit unsigned integer. The maximum time, in milliseconds,
between successive unsolicited Router Advertisement messages sent
by this router on this network interface.
Instead of printing the result of icmp6_cksum() if it's non-zero, print
the checksum field value and the value it should have had. That means
that what we print is the same regardless of whether we're running on a
big-endian or little-endian machine.
Use the EXTRACT_ macros to extract multi-byte integral values from
packets, rather than just dereferencing pointers into the packet; there
is no guarantee that the packet data will be aligned on the right
boundary, and there is no guarantee that, if they're not, a direct
access will work correctly.
at places where the entity to print / or increment
shares the semantics of an IPv4 or IPv6 address
use sizeof(in_addr) and sizeof(in6_addr),
rather than a hardcoded 4 or 16
-replace private flag printers and replace them with bittok2str()
-remove some flesh from inline printf() statements make more use of tok2str()
-option printer gets a multiline output (behind vflag)
-context hexdump for options
-replace some u_int32 with u_int8[4] to get around compiler padding issues
with the current IANA assignment (Apr 13 2004). It consists of the
following four parts:
- added inverse-neighbor-discovery (RFC3122)
- shift MTRACE-related type numbers, since it collides
with inverse-neighbor-discovery.
- added MLDv2 (draft-vida-mld-v2-08.txt)
- shifted Mobile-IPv6 numbers from interim value to the
official one. (draft-ietf-mobile-ipv6-24.txt)