Commit Graph

5147 Commits

Author SHA1 Message Date
Francois-Xavier Le Bail
fb154b00ba Build tcpdump with the libnetdissect library
No more link tcpdump with the printers object files.
2018-02-07 11:18:54 +01:00
Guy Harris
5413246819 Rename pcapng test files to .pcapng.
That makes it clearer which captures are pcap and which are pcapng, and
could allow us to, if we're testing with a tcpdump linked with a libpcap
that doesn't handle pcapng files, skip the pcapng files.
2018-02-06 18:56:52 -08:00
Guy Harris
1d8ae5400d Fix link-layer header type.
tcpdump doesn't care (the upper 16 bits of the link-layer header type
field in pcap frames is sort-of reserved for extensions - libpcap
separates it from the link-layer header type, and tcpdump doesn't look
at the extensions), but Wireshark does.
2018-02-06 18:44:05 -08:00
Guy Harris
511cd61cb4 Fix some more corrupt pcapng files, turning them into pcap files. 2018-02-06 17:56:29 -08:00
Guy Harris
9075a2857e Convert tests/arp-too-long-tha.pcap to a pcap file.
It was, its name nonwithstanding, a pcapng file, and had an SHB option
that was damaged by fuzzing.  Converting it to pcap

1) means it has the appropriate extension;

2) means that old libpcaps that can't read pcapng can handle it;

3) means that a future libpcap that fully supports pcapng *and* thus
fails on that file can handle it.
2018-02-06 16:11:53 -08:00
Francois-Xavier Le Bail
46f5203a8d Style update
Use parens around the sizeof argument, to match the style used elsewhere.
2018-02-06 20:01:55 +01:00
Francois-Xavier Le Bail
d714c9b427 Remove a duplicate test
stp-heapoverflow-5 is a duplicate of stp-heapoverflow-2, remove it.

$ git grep 'stp-heapoverflow-[25].pcap'
TESTLIST:stp-heapoverflow-2 stp-heapoverflow-2.pcap stp-heapoverflow-2.out -v
TESTLIST:stp-heapoverflow-5 stp-heapoverflow-5.pcap stp-heapoverflow-5.out -v

$ sha1sum tests/stp-heapoverflow-[25].pcap
8dcacae45e7922fc2b9714f0c35bd3c87cadb3e6  tests/stp-heapoverflow-2.pcap
8dcacae45e7922fc2b9714f0c35bd3c87cadb3e6  tests/stp-heapoverflow-5.pcap

$ sha1sum tests/stp-heapoverflow-[25].out
d0d0af7efc7b459273d8a7e9c761366bd4ecc835  tests/stp-heapoverflow-2.out
d0d0af7efc7b459273d8a7e9c761366bd4ecc835  tests/stp-heapoverflow-5.out
2018-02-06 15:14:35 +01:00
Guy Harris
a0f4e3003e Do time stamp deltas with unsigned arithmetic.
First, check whether the originate timestamp is greater than the other
timestamp and, if so, calculate (originate - other) and print a -
instead of a + before it.  This means we're not trying to stuff the
difference between two unsigned values into a signed value of the same
width (the result of which is undefined if the difference doesn't fit in
the signed variable).
2018-02-02 18:26:50 -08:00
Guy Harris
784b86ec5f Fix bug introduced by previous change.
We aren't post-decrementing the loop index after testing it, we're
decrementing it after the loop body is executed.
2018-02-01 16:06:06 -08:00
Guy Harris
6a42fb7011 Don't decrement an unsigned value past zero.
That also means we do one less decrement, so it's not as if testing
i-- rather than testing i and separately decrementing it is an
optimization.

Fix some types to unsigned while we're at it - and do the above change
for them, too.
2018-02-01 14:25:29 -08:00
Guy Harris
3582e7ac3d Don't decrement an unsigned value past zero.
That also means we do one less decrement, so it's not as if testing
exp-- rather than testing exp and separately decrementing it is an
optimization.
2018-02-01 14:19:08 -08:00
Guy Harris
95e7cd03e6 Don't decrement an unsigned zero value below zero.
In fact, don't waste time incrementing the pointer or decrementing the
count until we know that we're going to go through another trip through
the loop.  (This isn't a PDP-11 and probably isn't a VAX or 68k, so *p++
isn't going to be done by an addressing mode.)

This should fix an undefined-behavior warning.
2018-02-01 14:16:11 -08:00
Denis Ovsienko
2f713e9246 Babel: amend to match the specification better
In RFC 6126 TLV type 9 is "Route Request", TLV type 10 is "Seqno
Request" and the field in the IHU TLV is called "Rxcost". Make the
decoder spell those data items the same way. Add some comments and
update tests.
2018-02-01 20:14:16 +00:00
Denis Ovsienko
1a2997dde4 Babel: amend the previous change
Clarify the "invalid" string in MESSAGE_MH_REQUEST and add a similar
check for MESSAGE_NH.
2018-02-01 20:14:07 +00:00
Juliusz Chroboczek
303d5537a0 Fix printing of wildcard retractions and IHU in Babel printer.
When the AE field is 0, the message applies to any routes or
neighbours.  Tcpdump used to print it as ::/0, which is confusing.
2018-02-01 19:35:31 +00:00
Francois-Xavier Le Bail
8d814082b7 Add a sanity check on packet header capture length
The capture length must be <= MAXIMUM_SNAPLEN.

Now a pachet is valid if:
packet length != 0,
capture length != 0,
capture length <= MAXIMUM_SNAPLEN,
packet length >= capture length.

Moreover:
Fix spaces, indentation.
2018-02-01 18:58:02 +01:00
Francois-Xavier Le Bail
5dfebc9722 OSPFv3: More nd_ipv6-ification 2018-01-31 20:40:45 +01:00
Francois-Xavier Le Bail
0ee15606e2 Remove unneeded '&' when getting a pointer to a nd_ipv6 type 2018-01-31 16:43:50 +01:00
Francois-Xavier Le Bail
5922b80797 Remove unneeded '&' when getting a pointer to a nd_ipv4 type 2018-01-31 16:43:50 +01:00
Francois-Xavier Le Bail
90528d4c39 AODV: Use nd_ipv4 type for IPv4 addresses 2018-01-31 11:33:27 +01:00
Guy Harris
c2a9094394 Merge branch 'master' of github.com:the-tcpdump-group/tcpdump 2018-01-31 00:47:26 -08:00
Guy Harris
0dad1934af Have ip{6}addr_string take a u_char * as the second argument.
Fix warnings that introduces.
2018-01-31 00:43:45 -08:00
Francois-Xavier Le Bail
150fa329b5 Remove unneeded '&' when getting a pointer to a nd_ipv6 type 2018-01-31 08:33:31 +01:00
Francois-Xavier Le Bail
77ece6d435 Remove unneeded '&' when getting a pointer to a nd_ipv4 type 2018-01-31 08:31:16 +01:00
Guy Harris
44c822e9f6 More nd_ipv6-ification. 2018-01-30 21:06:06 -08:00
Guy Harris
398ef7f336 A bit more nd_ipv4-ification. 2018-01-30 17:30:54 -08:00
Guy Harris
3db38df8ed Use nd_ipv6 rather than struct in6_addr in packet-layout structures.
Also, use it, and nd_ipv4, in sizeof() operations.
2018-01-30 17:29:33 -08:00
Guy Harris
7f952dfbb3 Use EXTRACT_IPV4_TO_NETWORK_ORDER() when checking an address against 0.
It may do less work than EXTRACT_IPV4_TO_HOST_ORDER(), and the byte
order doesn't matter when comparing against 0.
2018-01-30 14:42:40 -08:00
Guy Harris
6babce0e17 Use nd_ipv4 rather than struct in_addr.
This ensures that we have no purportedly-aligned-but-not-necessarily-
unaligned values that we access; we have to use EXTRACT_ macros/functions
to get at IPv4 address values.
2018-01-30 14:39:15 -08:00
Francois-Xavier Le Bail
7755951df7 RT6: Replace 'struct in6_addr' members type with a 'nd_ipv6' one
In 'struct ip6_hdr', 'struct ip6_rthdr0' and 'struct ip6_srh'.
This avoid some 'undefined-behavior' warnings with clang and option
-fsanitize=undefined enabled.

print-rt6.c:66:3: runtime error: member access within misaligned address
0x61d00001eab6 for type 'const struct ip6_rthdr0', which requires 4 byte
alignment
0x61d00001eab6: note: pointer points here
 00 00 00 04 3a 02  00 01 00 00 00 00 22 00  00 00 00 00 02 10 00 02  00 00 00 00 00 04 80 00  d3 ab
             ^
SUMMARY: AddressSanitizer: undefined-behavior print-rt6.c:66:3 in
2018-01-30 22:17:36 +01:00
Francois-Xavier Le Bail
470c75a397 IPX: Use more the nd_uint32_t type
In 'struct ipxHdr'.
This avoid some 'undefined-behavior' warnings with clang and option
-fsanitize=undefined enabled.

print-ipx.c:79:2: runtime error: member access within misaligned address
0x61d00001ea91 for type 'const struct ipxHdr', which requires 2 byte alignment
0x61d00001ea91: note: pointer points here
 54 e0 e0  03 ff ff 00 50 00 14 00  00 00 00 ff ff ff ff ff  ff 04 55 a8 f8 79 67 00  00 00 00 00 01
              ^
SUMMARY: AddressSanitizer: undefined-behavior print-ipx.c:79:2 in
2018-01-30 20:13:15 +01:00
Francois-Xavier Le Bail
aa9960a2c3 ICMP: Replace a 'struct in_addr' member type with a 'nd_ipv4' one
In 'struct icmp'.
This avoid some 'undefined-behavior' warnings with clang and option
-fsanitize=undefined enabled.

Moreover:
Remove unneeded '&' when getting a pointer to a nd_ipv4 type.
Fix indentation.

The warnings were like:
print-icmp.c:355:2: runtime error: member access within misaligned address
0x61d00001eabe for type 'const struct icmp', which requires 4 byte alignment
0x61d00001eabe: note: pointer points here
 ef 01 02 03 08 00  90 e1 00 03 00 00 00 00  00 00 00 05 ed 60 ab cd  ab cd ab cd ab cd ab cd  ab cd
             ^
SUMMARY: AddressSanitizer: undefined-behavior print-icmp.c:355:2 in
2018-01-30 16:38:48 +01:00
Francois-Xavier Le Bail
fbe65c7e38 HSRP: Replace a 'struct in_addr' member type with a 'nd_ipv4' one
In 'struct hsrp'.
This avoid some 'undefined-behavior' warnings with clang and option
-fsanitize=undefined enabled.

Moreover:
Remove unneeded '&' when getting a pointer to a nd_ipv4 type.

The warnings were like:
print-hsrp.c:102:2: runtime error: member access within misaligned address
0x61d00001eaaa for type 'const struct hsrp', which requires 4 byte alignment
0x61d00001eaaa: note: pointer points here
 00 1c  2d 8d 00 00 10 03 0a 64  01 00 63 69 73 63 6f 00  00 00 c0 a8 00 01 be be  be be be be be be
              ^
SUMMARY: AddressSanitizer: undefined-behavior print-hsrp.c:102:2 in
2018-01-30 16:38:37 +01:00
Guy Harris
ace2828188 Add ws2_32, not socket and nsl, if ws2_32 has gethostbyaddr().
Also, fail if we don't have gethostbyaddr(), either on Windows or on
UN*X.

Suppress some UN*X-only tests on Windows while we're at it.
2018-01-30 02:41:43 -08:00
Guy Harris
0f0600c901 Get rid of tests whose results we don't use.
(Crud left over from using libpcap's CMakeLists.txt as a basis for this
one.)
2018-01-30 02:18:31 -08:00
Guy Harris
5d55ad3761 Put back an #endif.
Include <stdio.h> on Digital/Tru64 UNIX to get snprintf(); we assume the
versions on which people will build this (if any) will have it.  (1998
called, they want their C library back....)
2018-01-29 16:23:11 -08:00
Guy Harris
c499612a7f Add nd_{v}snprintf() routines/wrappers.
Some versions of the MSVC runtime library have a non-C99-compliant
vsnprintf(), which we want to avoid.  On Windows, use snprintf() and
vsnprintf() for VS 2015 and later, where they both exist in
C99-compliant forms, and wrap _{v}snprintf_s() otherwise (they're
guaranteed to do the null termination that we want).
2018-01-29 15:48:55 -08:00
Guy Harris
1e120597d2 Don't define {v}snprintf() as _{v}snprintf(); they're not the same.
They don't behave exactly like ISO C {v}snprintf(), so, on Windows, we
have wrappers around _{v}snprintf() that behave the way {v}snprintf()
are supposed to work.
2018-01-29 13:55:08 -08:00
Guy Harris
b5e459c67f It's tcpdump, not pcap. 2018-01-29 13:41:43 -08:00
Guy Harris
458fa5ea7b First cut at a YML file for AppVeyor. 2018-01-29 13:36:30 -08:00
Guy Harris
e68daf3cd9 Put UNALIGNED_OK at the beginning of the inline declaration.
Stylistic consistency - it's a characteristic of the function, so put it
in the list of characteristics, along with "static" and "inline".
2018-01-29 11:58:31 -08:00
Francois-Xavier Le Bail
3437ef001c LWRES: Use more EXTRACT_U_1() macro 2018-01-29 15:48:31 +01:00
Guy Harris
3fbbef3e68 Squelch warnings from MSVC.
Use float values, rather than double values, to initialize an array of
floats.
2018-01-29 02:30:48 -08:00
Guy Harris
7b909aba81 Squelch warnings from MSVC.
Use float values, rather than double values, to initialize an array of
floats.
2018-01-29 02:25:56 -08:00
Guy Harris
0fb509808c Not all Windows pcaps have pcap_wsockinit().
WinPcap 4.1.3 has only wsockinit(); check for both, on Windows.
2018-01-29 02:16:13 -08:00
Guy Harris
ffe074feba Work around a WinPcap botch. 2018-01-29 02:04:12 -08:00
Guy Harris
a13e29249b Extra libraries needed on Windows. 2018-01-29 01:54:48 -08:00
Guy Harris
6ed7ed4711 Another UN*Xism we need - isascii().
I guess it's not in ISO C because the character set of an ISO C
implementation isn't necessarily ASCII (EBCDIC, in IBM's C for z/OS and
IBM i).
2018-01-29 01:44:30 -08:00
Guy Harris
c7dfcd6aaf When checking pcap.h, make sure we look in ${PCAP_INCLUDE_DIRS}.
It's not necessarily in one of the default include directories, so look
in the directory where we're supposed to look for pcap header files.
2018-01-29 01:30:20 -08:00
Guy Harris
c1094815c3 Let CMake figure out whether we have snprintf() or not.
Now that we're using check_symbol_exists(), CMake can find it, so we
don't need to check the compiler version - and this avoids a warning
about redefining HAVE_SNPRINTF.
2018-01-29 01:10:25 -08:00