Commit Graph

4426 Commits

Author SHA1 Message Date
Guy Harris
39be365bae Call it 4.10.0-PRE-GIT for now. 2017-02-04 19:12:46 -08:00
Denis Ovsienko
5512e02f3a Prevent hyphenation for the e-mail address.
It did not look right in the text version of the man page.
2017-02-04 18:09:41 +00:00
Tony Samuels
2c2a62e74f Fix typo in printing full name of CFM's CCM opcode value. 2017-02-04 13:23:26 +00:00
Denis Ovsienko
1996a04789 Travis CI: show tcpdump version in the build log
The interesting part is whether the build has picked up the optional
libraries that were present and whether AddressSanitizer was enabled
(this is yet to be sorted in some reasonable way).
2017-02-03 16:03:08 +00:00
Denis Ovsienko
3a47232799 Show AddressSanitizer presence in version output.
This may help to understand some bug reports.
2017-02-03 15:34:43 +00:00
Denis Ovsienko
78279f51bc GRE: Add a couple comments about the bounds. 2017-02-03 14:15:13 +00:00
Francois-Xavier Le Bail
ae859d7db1 Fix changes for 4.8.1/4.9.0 releases 2017-02-03 14:39:29 +01:00
Denis Ovsienko
9a8d65aa40 fix a typo in a comment 2017-02-02 22:43:01 +00:00
Denis Ovsienko
a5830b4314 use constant macros for OTV and VXLAN-GPE 2017-02-02 22:42:50 +00:00
Denis Ovsienko
a13a19a610 OSPF: refine unknown packet type handling
As far as modern OSPF implementations are concerned, packet type 0 is
not a valid value, so let's print it as such. Also for an invalid packet
type tell its decimal value.
2017-02-02 20:55:03 +00:00
Guy Harris
1fb50928ce Regenerate config files. 2017-02-02 12:19:28 -08:00
Guy Harris
b8c56aa092 Merge pull request #588 from glebius/casper
Add support for libcasper library available on FreeBSD 11.0 and newer.
2017-02-02 12:18:56 -08:00
Denis Ovsienko
efd50b3e14 add a GitHub issue template 2017-02-02 13:24:13 +00:00
Denis Ovsienko
be1e19f50c refine the feedback guidelines
Provide better detailed guidelines in CONTRIBUTING and update a number
of other files to refer to that file so that the directions are now
more uniform.
2017-02-02 11:38:05 +00:00
Denis Ovsienko
4507858182 remove some trailing space 2017-02-02 11:38:05 +00:00
Luigi Rizzo
8830c2865e add CAP_EVENT for the libpcap device
...so we will be able to use pcap-netmap, which does poll() on the file
descriptor.
2017-02-02 11:38:05 +00:00
SUGYO Kazushi
08eea54b99 convert KAME "setkey -D" to esp-secrets-file
This resolves GitHub issue #26 completely.
2017-02-02 11:37:56 +00:00
Gleb Smirnoff
cd3c5880b1 Add support for libcasper library available on FreeBSD 11.0 and newer.
The patch allows tcpdump to run sandboxed and still do name resolution.

The code is obtained from FreeBSD tree, where it was developed by

Pawel Jakub Dawidek <pjd@FreeBSD.org>
Mariusz Zaborski <oshogbo@FreeBSD.org>
2017-02-01 16:13:05 -08:00
Denis Ovsienko
cae54f4d94 CVE-2016-7985,7986/fixup medsa_print()
The code in medsa_print() assumed that the MEDSA packet always follows
an Ethernet header that is inside the allocated memory buffer. But
this is not always the case, see commit 6bc4429 for rationale.

Eliminate the Ethernet header pointer and just pass on the struct
lladdr_info arguments provided.
2017-01-18 18:24:53 +00:00
Francois-Xavier Le Bail
2cc01cb08d Add changes for 4.9.0 release 2017-01-18 10:55:25 +01:00
Guy Harris
8ca206d704 Use INT32_MIN to check for the smallest possible 32-bit signed value.
-2147483648 provokes warnings, for various reasons involving the
definition of a constant in C, the rules of picking the type of a
constant, and the rules for determining the type of an expression
involving an integral value and the - operator.  (Note that
-2147483648isn't a decimal-constant in C90 or C99, as a decimal-constant
can't contain a -.  Therefore, it's a constant expression, consisting of
the - operator applied to the constant 2147483648.)

So we use INT32_MIN, which should at least make an effort to avoid those
warnings.
2017-01-18 09:16:42 +01:00
Francois-Xavier Le Bail
12d939c3e9 The option -n is useless in TESTLIST
This option is already set in TESTonce.
2017-01-18 09:16:42 +01:00
Guy Harris
40185ca67a Discard result of fn_printn() calls.
We've already done checks to see whether we'll run past the end of the
packet, so there's no need to see whether fn_printn() did so.

Squelches some Coverity complaints.
2017-01-18 09:16:42 +01:00
Denis Ovsienko
77b9208db0 CVE-2017-5205/add a test case
The .pcap file comes from Francois-Xavier Le Bail.
2017-01-18 09:16:42 +01:00
Guy Harris
51d66a246a CVE-2017-5205/Clean up parsing of IKEv2 Security Associations.
The payload of a Security Association has a sequence of proposal
substructures; the Last Substruc field should only be 0 (for the last
proposal substructure) or 2 (if there's another proposal substructure
after the current one).  If it's neither, don't try to dissect the next
item as a payload with the Last Substruc field's value as a payload
type.

The payload of a proposal substructure has a sequence of transform
substructures; the Last Substruc field should only be 0 (for the last
transform substructure) or 3 (if there's another transform substructure
after the current one).  If it's neither, don't try to dissect the next
item as a payload with the Last Substruc field's value as a payload
type.

That keeps us from trying to, for example, dissect a bogus substructure
as an encrypted payload item and passing a null pointer as the struct
isakmp structure pointer.

Do more checks while we're at it.
2017-01-18 09:16:42 +01:00
Guy Harris
892603ab28 Use ND_TCHECK_32BITS() before EXTRACT_32BITS().
It makes it a bit clearer what's being done.
2017-01-18 09:16:42 +01:00
Denis Ovsienko
f152c1268f CVE-2017-5485/add the test case 2017-01-18 09:16:42 +01:00
Denis Ovsienko
d07f724227 CVE-2017-5486/add the test case 2017-01-18 09:16:42 +01:00
Guy Harris
fe62ab3744 Clean up white space. 2017-01-18 09:16:42 +01:00
Guy Harris
e7f2e5fdab Make sure we have the entire option before printing it. 2017-01-18 09:16:42 +01:00
Guy Harris
d33705dab6 Use fn_printn() to print strings.
Don't just use %.*s - that's not robust in the presence of non-printable
characters in the string.
2017-01-18 09:16:42 +01:00
Guy Harris
2817174698 CVE-2017-5485/Fix lookup_nsap() to match what isonsap_string() expects.
Change cddcb5632d changed isonsap_string()
to take, as arguments, a pointer to the first octet of an NSAP and the
length of the NSAP, rather than a pointer to a string of octets the
first octet of which is the NSAP length and the subsequent octets are
the octets of the NSAP.

However, lookup_nsap() was not changed in a similar fashion, and
isonsap_string() handed it a pointer to the first octet of the NSAP,
which lookup_nsap() treated as the NSAP length.

This should fix GitHub issue #563.
2017-01-18 09:16:42 +01:00
Guy Harris
b553848e3e CVE-2017-5486/Do ND_TCHECK2 bounds checks on source and destination addresses.
Those are needed in addition to the checks against li.

This should fix GitHub issue #562.  I suspect issue #563 is a separate
problem.

Tweak length check messages to be more like the IS-IS ones, and fix both
to print unsigned values with %u, while we're at it.
2017-01-18 09:16:42 +01:00
Denis Ovsienko
5d214e36ee CVE-2017-5484/ATM: fix an incorrect bounds check
The function sig_print() did receive a correct caplen parameter value
but didn't use it correctly and could overread by one byte as Brian
Carpenter has demonstrated. Fix it by switching to the standard macros.
2017-01-18 09:16:42 +01:00
Guy Harris
8851b44c8d Add more checks.
Check that the destination and source addresses are present before
printing them.

Check the length value from the length indiator as we dissect the CLNS
header.  Make sure that header doesn't go past the on-the-network length
of the packet.

Check to make sure an option's content doesn't go past the length of the
option.

Also, don't print the body of an unknown option type twice with -vv and
more.
2017-01-18 09:16:41 +01:00
Denis Ovsienko
eec1624f7b CVE-2017-5483/SNMP: improve ASN.1 bounds checks
Kamil Frankowicz had found that truncated BE_STR and BE_SEQ ASN.1
elements could lead to an overread, from the source code it looked like
other ids could have this problem too. Move the checks introduced in
commit 72e501f out of the switch blocks to cover all ids by default.
This fixes GH#559 and GH#566.
2017-01-18 09:16:41 +01:00
Denis Ovsienko
c39c1d99ac CVE-2017-5482/Q.933: add a missing bounds check
Brian Carpenter had found that regardless of CVE-2016-8575 q933_print()
still could overread the buffer trying to parse a short packet. This
change fixes the problem.
2017-01-18 09:16:41 +01:00
Denis Ovsienko
857ec6e800 pass correct caplen to other functions as well
In ethertype_print(), isoclns_print() and snap_print() adjust the length
arithmetics along the same lines as for ether_print() in the previous
commit. Where done, the current pointer is not greater than snapend so
that the difference (i.e. caplen) is never negative.

This does not fix a reported issue but the problem was very likely to be
there.
2017-01-18 09:16:41 +01:00
Denis Ovsienko
0db4dcafe5 CVE-2017-5342/pass correct caplen value to ether_print()
In that function the "length" parameter means off-the-wire length, that
is, the length declared inside the outer header. The "caplen" parameter
means the amount of bytes actually available in the captured packet.

gre_print_0() and the functions modelled after it passed the value of
"length" instead of the value of "caplen", this could make ether_print()
access beyond the memory allocated for the captured packet. Brian
Carpenter had demonstrated this for the OTV case.

Fix the involved functions that call ether_print() to pass the correct
value and leave a comment to dismiss "caplen" later as its value can be
reliably derived from the other ether_print() parameters.
2017-01-18 09:16:41 +01:00
Denis Ovsienko
409ffe9452 CVE-2017-5341/OTV: add missing bounds checks
Interleave the bounds checking with printing to make it visible which
last protocol field was OK. This fixes a vulnerability discovered by
Brian Carpenter.
2017-01-18 09:16:41 +01:00
Denis Ovsienko
d6913f7e3f CVE-2017-5204/IPv6: fix header printing
Add a few checks to ip6_print() to make it stop decoding the IPv6
headers immediately when the header-specific functions signal an error
condition. Without this it tried to fetch the next header selector for
the next round regardless and could run outside of the allocated packet
space on a specially crafted IPv6 packet.

Brian Carpenter has demonstrated this for the Hop-by-Hop Options header.
Fix that specific case and also the Destination Options and Fragment
header processing as those use the same logic.
2017-01-18 09:16:41 +01:00
Francois-Xavier Le Bail
909fb30769 CVE-2017-5202/ISOCLNS: Add two bounds checks
This fix GitHub issue #558
2017-01-18 09:16:41 +01:00
Francois-Xavier Le Bail
496be87393 CVE-2017-5203/BOOTP: Add a bounds check
This fix GitHub issue #557
2017-01-18 09:16:41 +01:00
Denis Ovsienko
4804e66125 TCP: put TCP-AO option decoding right
As it was correctly pointed out in GitHub issue #516, the TCPOPT_TCPAO
(formerly TCPOPT_AUTH) case had an issue with option length processing,
though without significant consequences thanks to a check elsewhere.
Besides that, the old code (introduced in 2005) decoded a structure
similar to a proposed encoding variant of the early (first published in
2007) revisions of the Internet-Draft but different from the encoding
of RFC 5925 (published in 2010). These issues are now addressed and the
TCP option renamed to TCP-AO.
2017-01-18 09:16:41 +01:00
Denis Ovsienko
e9ac8b2c85 amend the TCP authentication test case
Edit the .pcap file to change the TCP option kind from 20 to 29 to
match the changes done to the decoder. Now the code flow and hence
the text output are back to how they were before that change.
2017-01-18 09:16:41 +01:00
Denis Ovsienko
6b09339831 TCP: add a test case for the previous commit
The SCPS TCP option is malformed as discussed in GitHub issue #516 and
is printed as such. The .pcap file was contributed by Patrik Lundquist.
2017-01-18 09:16:41 +01:00
Patrik Lundquist
2857c0bded Correct TCP option Kind value for TCP Auth and add SCPS-TP.
Fixes first problem in issue #516 while the second one isn't broken in tcpdump.
2017-01-18 09:16:41 +01:00
Guy Harris
67b7b0a0e8 Clean up the "have libsmi but no modules loaded" case.
Have asn1_print() print out OIDs regardless of whether we have any
modules loaded or not.

Have smi_decode_oid decode the OID to an array of unsigned ints
regardless of whether we have any modules loaded or not.

Have smi_print_variable() just use asn1_print() to print the OID of a
variable binding if we don't have any modules loaded; in that case,
we're not going to try to look the OID up with libsmi, so we don't need
a decoded version.

Have smi_print_value() not bother decoding the OID or looking the OID up
if we don't have any modules loaded; also, if we *do* have modules
loaded, check whether smi_decode_oid() succeeds.
2017-01-18 09:16:41 +01:00
Guy Harris
d3a64d8365 Do better checking of RESP packets.
Don't call strtol() on the contents of a packet; there is *no* guarantee
that it won't run past the end of the buffer, as the buffer isn't a
null-terminated string.  Instead, have our own routine to parse ASCII
numbers (based on the FreeBSD strtol()), which uses ND_TCHECK() and
checks against the on-the-wire length to ensure it doesn't go past the
end of the packet or the end of the captured data.  Have it check for
other errors as well, such as checking for negative lengths that aren't
-1.

Clean up other aspects of the packet parsing.  Have them check the
on-the-wire length as well as the captured length.

Update the results of the resp_3 test.
2017-01-18 09:16:41 +01:00
Guy Harris
410956bc36 Clean up the object abbreviation list.
Have the OID prefixes be arrays of uint8_t, and put the size of the
array into the list, rather than having them be "strings" and et the
length with strlen().

Have a macro to encapsulate X.690 section 8.19.4's rules for the first
octet of an OID value, and use it; that makes the components of the OID
clearer.

Also, if the prefix is longer than the remaining data in the OID - or
the remaining captured data - just skip it, don't treat that as an
error.
2017-01-18 09:16:40 +01:00