mkirkhart [Wed, 4 Feb 2015 23:55:58 +0000 (18:55 -0500)]
Fixed bug in arp_print() in handling of inverse arp responses - the target's hardware and protocol address were being printed instead of the sender's hardware and protocol address
Guy Harris [Tue, 27 Jan 2015 19:38:31 +0000 (11:38 -0800)]
Merge pull request #422 from tbeadle/capng_changes
Make sure to init capng before dropping root.
capng_clear needs to be called before capng_change_id can be called within
droproot. Otherwise, an (unusable) error message is output: "error : ret -1" and it fails to drop root privileges.
This also fixes the dropping of the CAP_SETGID capability. Previously,
CAP_SETUID was being dropped twice.
Tommy Beadle [Tue, 27 Jan 2015 18:32:14 +0000 (13:32 -0500)]
Make sure to init capng before dropping root.
capng_clear needs to be called before capng_change_id can be called within
droproot. Otherwise, an (unusable) error message is output: "error : ret -1".
This also fixes the dropping of the CAP_SETGID capability. Previously,
CAP_SETUID was being dropped twice.
Guy Harris [Thu, 8 Jan 2015 21:22:13 +0000 (13:22 -0800)]
No OPER-TLV are "empty TLVs".
As section 7 of RFC 5810 says, an OPER-TLV is 1*PATH-DATA-TLV, so it
always has at least one PATH-DATA-TLV. Remove the ZERO_TTLV check - the
old one was bogus ((!ops->flags & ZERO_TTLV) means ((!ops->flags) &
ZERO_TTLV), and if ops->flags is non-zero, !ops->flags is zero, and the
test fails), and the new one causes tests to fail, revealing that the
whole "empty TLVs like COMMIT and TRCOMMIT are empty, we stop here"
think is wrong, so we remove it.
Denis Ovsienko [Sat, 3 Jan 2015 07:24:12 +0000 (07:24 +0000)]
ICMPv6: fix RPL DAGID printing (GH #418)
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.
Denis Ovsienko [Tue, 30 Dec 2014 20:29:57 +0000 (20:29 +0000)]
skip some tests when compiled with Capsicum
When compiled with Capsicum, tcpdump -E 'file filename' fails to read
the secret from the file with the "Not permitted in capability mode"
error and exits with code 3. Skip respective tests until this logic is
handled in a better way.
Denis Ovsienko [Mon, 29 Dec 2014 11:02:17 +0000 (11:02 +0000)]
fix compilation on FreeBSD 10.1
Commit 05d7191 fixed detection of Capsicum availability and the
Capsicum-specific code in tcpdump made it into the compilation process
on respective FreeBSD systems. However, it would fail to compile at
least on FreeBSD 10.1-RELEASE as quoted below. This commit fixes it.
In file included from ./tcpdump.c:89:
/usr/include/net/bpf.h:65:8: error: redefinition of 'bpf_program'
struct bpf_program {
^
../libpcap/pcap/bpf.h:106:8: note: previous definition is here
struct bpf_program {
^
In file included from ./tcpdump.c:89:
/usr/include/net/bpf.h:1206:8: error: redefinition of 'bpf_insn'
struct bpf_insn {
^
../libpcap/pcap/bpf.h:1466:8: note: previous definition is here
struct bpf_insn {
^
2 errors generated.
Guy Harris [Fri, 19 Dec 2014 21:44:21 +0000 (13:44 -0800)]
Assume non-buggy getaddrinfo() when cross-compiling.
The cross target is probably some flavor of Linux (this includes
Android) or *BSD (or maybe iOS if you're building for a jailbroken
system), and those should have non-buggy getaddrinfo().
If somebody's cross-compiling for a target with a buggy getaddrinfo(),
and tcpdump incorrectly converting IPv6 addresses to host names causes
the universe to collapse into a giant black hole or something equally
horrible, too bad.
Guy Harris [Fri, 19 Dec 2014 09:58:26 +0000 (01:58 -0800)]
Only print the incorporated IP packet if there is one.
Check for the ICMP types that *do* include an IP packet, rather than
checking for a set that doesn't. This does a better job of handling
unknown ICMP types.
Guy Harris [Thu, 18 Dec 2014 23:51:11 +0000 (15:51 -0800)]
Fix length checking.
Check both the captured length and the on-the-wire length (the latter
*should* be greater than or equal to the former, but that's not
guaranteed).
Add some additional length checks, so neither caplen nor length
underflow.
If we stop dissecting because the packet is too short, return 1, not 0,
as we've "dissected" what we can; 0 means "this is LLC+SNAP with an OUI
of 0 and an unknown Ethertype".
Denis Ovsienko [Fri, 12 Dec 2014 23:34:20 +0000 (23:34 +0000)]
OpenFlow: improve vendor message decoding
Introduce a new function that tries to dispatch an OFPT_VENDOR message
to a vendor-specific printer function. Add such a function for Big
Switch Networks vendor with about as little decoding as necessary to
cover the existing 7050Q OF1.0 capture.
Denis Ovsienko [Thu, 11 Dec 2014 23:49:30 +0000 (23:49 +0000)]
OpenFlow: add vendor name printing
The new function goes into print-openflow.c as vendor name decoding is
the same in all versions of OpenFlow (although in 1.0 it is "vendor"
and in subsequent versions it is "experimenter"). The mapping is from:
Francois-Xavier Le Bail [Mon, 8 Dec 2014 21:18:16 +0000 (22:18 +0100)]
OLSR: fix "Unchecked return value" found by Coverity
The bounds check is already done before by ND_TCHECK2(*msg_data, addr_size +
name_entry_len + name_entry_padding).
So we are deliberately ignoring the return values of fn_printn with last
argument NULL (no bounds check).
Francois-Xavier Le Bail [Mon, 8 Dec 2014 20:24:59 +0000 (21:24 +0100)]
CDP: fix "Unchecked return value" found by Coverity
The bounds check is already done before by ND_TCHECK2(*tptr, len).
So we are deliberately ignoring the return values of fn_printn with last
argument NULL (no bounds check).
Francois-Xavier Le Bail [Fri, 14 Nov 2014 19:14:29 +0000 (20:14 +0100)]
TESTonce & others: 'make check' need to do a strict comparison, including spaces
Currently, TESTonce uses 'diff -w' so it ignores all white space.
We need a strict comparison, else there is no difference between, for example,
'Association Setup' and 'AssociationSetup' => removing the option '-w'
Guy Harris [Wed, 12 Nov 2014 03:05:48 +0000 (19:05 -0800)]
Further cleanups.
Use ND_TCHECK() rather than home-brew bounds checks. Do simpler length
checks.
Let i be the length of the actual remaining packet data; use ND_TCHECK()
inside loops that iterate over the remaining data.
Let the printers for particular message types cast the raw data pointer
to a pointer of the appropriate type, rather than passing two pointers,
with different types, to the same data.
Guy Harris [Wed, 12 Nov 2014 01:24:12 +0000 (17:24 -0800)]
Add initial bounds check, get rid of union aodv.
Fetch the type field without using a structure, and check to make sure
it's not past the end of the packet.
Pass to each dissection routine a pointer to the appropriate message
type structure, rather than a pointer to a union of all the message type
structures.
Guy Harris [Mon, 10 Nov 2014 07:24:53 +0000 (23:24 -0800)]
Use ND_TCHECK() to do bounds checking.
While we're at it, just use the record count to when iterating over
records; the ND_TCHECK()s will make sure we don't run past the end of
the captured data.
Also get rid of an unused argument to cnfp_print().
Baruch Siach [Wed, 29 Oct 2014 11:21:05 +0000 (13:21 +0200)]
Use system libpcap when configured with --with-system-pcap
Don't force the local libpcap build when the system provides one. When
--with-system-pcap is given to configure, don't try to locate a local libpcap
build. This help build systems like Buildroot that store build trees in the
same directory, but still prefer dynamically linking against system wide
libpcap.so to save space.
Guy Harris [Mon, 20 Oct 2014 21:44:47 +0000 (14:44 -0700)]
Fix length fields in UDP headers to be what they should be.
The value of the length field in a UDP header includes the length of the
header itself; the values in this capture didn't. The length fields in
the IP headers and the RADIUS headers were correct and consistent with
each other, and the length fields in the UDP headers are now correct and
consistent with both of them.
Pass a pointer to the struct pkt_top to wb_dops, and calculate the
address of the first struct dophdr there. Check each struct dophdr
before printing it. Hopefully this will quiet a Coverity complaint.
Guy Harris [Sun, 19 Oct 2014 20:42:00 +0000 (13:42 -0700)]
Use the length field in the UDP header.
If it's less than the length of the IP payload, use it as the size of
the UDP packet. If it's greater than the length of the IP payload,
and we're not dissecting the payload, report the length as bad.