Commit Graph

4363 Commits

Author SHA1 Message Date
Guy Harris
d9e65de3d9 CVE-2017-11108/Fix bounds checking for STP.
Check whether the flags are in the captured data before printing them in
an MSTP BPDU.

Check whether V4 length is in the captured data before fetching it.
This fixes a vulnerability discovered by Kamil Frankowicz.

Include a test for the "check whether the V4 length is..." fix, using
the capture supplied by Kamil Frankowicz.
2017-07-22 23:57:42 +01:00
Guy Harris
1bf91b1413 Squelch some alignment warnings.
Make src and dst "const void *"s to squelch

    taking address of packed member 'ip6_dst' of class or structure
    'ip6_hdr' may result in an unaligned pointer value
    [-Waddress-of-packed-member]

warnings from some versions of Clang.
2017-07-22 13:25:46 -07:00
Guy Harris
4bce81542c Squelch some alignment warnings.
Make dst_addr a "const void *" to squelch

    taking address of packed member 'ip6_dst' of class or structure
    'ip6_hdr' may result in an unaligned pointer value
    [-Waddress-of-packed-member]

warnings from some versions of Clang.
2017-07-22 13:24:15 -07:00
Denis Ovsienko
f92b6812d0 RSVP: add two missing breaks
Add a break at the end of the RSVP_OBJ_LABEL_SET case block as it fully
deals with class number 36 (LABEL_SET) from RFC 3473 Section 2.6 and is
not related to the class in next case block.

Add a break at the end of the RSVP_OBJ_S2L case block as it fully deals
with class number 50 (S2L_SUB_LSP) from RFC 4875 Section 19.3 and does
not need to fall through to the default case block.
2017-07-22 19:35:06 +01:00
Denis Ovsienko
26a4aa405a Frame Relay: denote a genuine fall through case
The source code comment explains it should fall through but GCC does not
pick it up, that's what the new macro is for.

./print-fr.c: In function ‘mfr_print’:
./print-fr.c:510:20: warning: this statement may fall through [-Wimplicit-fallthrough=]
                 if (ie_len == sizeof(struct timeval)) {
                    ^
./print-fr.c:521:13: note: here
             case MFR_CTRL_IE_VENDOR_EXT:
             ^~~~
2017-07-22 19:35:06 +01:00
Denis Ovsienko
6df678ca31 Check for __attribute__ ((fallthrough)) (GCC 7).
The documentation claims that recent GCC is now better by default at
spotting cases of code flow falling through (which is true) and that it
avoids false positives by matching nearby source code comments with
regexps. However, the latter feature doesn't seem to work as reliably
as the manual describes it, so let's have a macro for this purpose.

Tested to work on:
* x86_64, Fedora 26, GCC 7.1.1 (w/__attribute__, w/fallthrough)
* x86_64, Ubuntu 16.04, GCC 5.4.0 (w/__attribute__, w/o fallthrough)
* x86_64, FreeBSD 11.0, CLang 3.8.0 (w/__attribute__, w/o fallthrough)
* SPARC, Solaris 10, SolStudio 12.4 (w/__attribute__, w/o fallthrough)
* SPARC, Solaris 10, SunStudio 11 (w/o __attribute__)
2017-07-22 19:33:49 +01:00
Denis Ovsienko
11fcafcf69 HNCP: refine snprintf() buffers sizing
This squelches a warning in format_256(), make a similar change to
format_nid() while at it.

$ gcc --version
gcc (GCC) 7.1.1 20170622 (Red Hat 7.1.1-3)

./print-hncp.c: In function ‘format_256’:
./print-hncp.c:175:26: warning: ‘%016lx’ directive output truncated writing 16 bytes into a region of size 12 [-Wformat-truncation=]
     snprintf(buf[i], 28, "%016" PRIx64 "%016" PRIx64 "%016" PRIx64 "%016" PRIx64,
                          ^~~~~~
./print-hncp.c:175:41: note: format string is defined here
     snprintf(buf[i], 28, "%016" PRIx64 "%016" PRIx64 "%016" PRIx64 "%016" PRIx64,
./print-hncp.c:175:26: note: using the range [0, 18446744073709551615] for directive argument
     snprintf(buf[i], 28, "%016" PRIx64 "%016" PRIx64 "%016" PRIx64 "%016" PRIx64,
                          ^~~~~~
./print-hncp.c:175:26: note: using the range [0, 18446744073709551615] for directive argument
./print-hncp.c:175:26: note: using the range [0, 18446744073709551615] for directive argument
./print-hncp.c:175:5: note: ‘snprintf’ output 65 bytes into a destination of size 28
     snprintf(buf[i], 28, "%016" PRIx64 "%016" PRIx64 "%016" PRIx64 "%016" PRIx64,
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          EXTRACT_64BITS(data),
          ~~~~~~~~~~~~~~~~~~~~~
          EXTRACT_64BITS(data + 8),
          ~~~~~~~~~~~~~~~~~~~~~~~~~
          EXTRACT_64BITS(data + 16),
          ~~~~~~~~~~~~~~~~~~~~~~~~~~
          EXTRACT_64BITS(data + 24)
          ~~~~~~~~~~~~~~~~~~~~~~~~~
     );
     ~
2017-07-20 21:04:56 +01:00
Denis Ovsienko
d72adb9406 Fix a bug in test scripts (exposed in GH #613).
crypto.sh ran its tests as expected but only indicated a failure
upstream when the last test failed. Add necessary checks and modify
the other "complex" tests in a similar manner to make sure the same
bug does not creep into these scripts later. Fix some indentation
while at it.
2017-07-13 21:18:23 +01:00
Guy Harris
27634837cc Force -t on in TESTonce.
These tests may be performed in an arbitrary time zone, so they *must*
run tcpdump with an option to print the time in a time-zone-independent
fashion.  Force -t on in TESTonce, just as we do for -n, and remove it
from TESTLIST and the conditional test scripts.
2017-07-01 23:17:02 +01:00
Guy Harris
8432c2a9f3 Cast ISIS_COMMON_HEADER_SIZE to u_int before printing it with %u.
It's a sizeof, so it's not necessarily the right size for %u.
2017-06-05 13:37:24 -07:00
Guy Harris
449682d899 With no -s, or with -s 0, don't specify the snapshot length with newer versions of libpcap.
That leaves it up to libpcap to choose an appropriate snapshot length,
which it'll do.  With upcoming versions, it'll choose, when capturing on
a D-Bus interface, a very large snapshot length, to handle the maximum
D-Bus message size of 128MB.

(For older versions, we still use 262144, as those versions won't pick a
default value.)
2017-06-02 21:50:45 -07:00
Guy Harris
0a515812de Don't set ndo_snaplen, either.
It's *not* the length of the captured data in the packet, it's the
snapshot length for the live capture or the savefile - the length of the
captured data in the packet could be less.
2017-06-02 20:10:49 -07:00
Guy Harris
c88fd3333f Get rid of last printer use of ndo_snaplen. 2017-06-02 20:06:29 -07:00
Guy Harris
a26c2b2425 Clean up IS-IS printing.
Check the packet length as well as the captured length.

Don't have separate "non-verbose" and "verbose" cases, so we don't
duplicate the length checks.

Print the right value for some length check errors.

Clean up the TLV parsing code - keep parsing until we completely run out
of data, but make sure, before we look at the TLV header, that we
haven't run past the end of the packet as well as that we haven't run
past the end of the captured data.

In the OSI checksum routine:

Have it take an unsigned length, so we don't have to worry about it
being negative.

Use ND_TTEST2 to check whether the checksum offset is within the
bounds of the packet.

If we don't have all the packet data to checksum, just report
"unverified", don't return a "truncated" error.
2017-06-02 20:05:12 -07:00
Job Snijders
da97db5c44 RFC 6608 specifies subcode 0 to be value "Unspecified Error" 2017-06-01 10:24:41 +01:00
Guy Harris
e48f4ca6ca Clean up the output format description somewhat.
Put the information about the time stamp first, and put in a more
detailed description of IPv4 header information before TCP header
information is described.

Update the description of TCP header informaton to reflect current
reality.

More updating is probably needed.
2017-05-23 13:39:57 -07:00
Guy Harris
5f718c2742 tcpdump can be of use for people who known nothing of TCP, these days.
The "tcp" in "tcpdump" is historical; these days, it's a general-purpose
network analyzer.  Don't claim tcpdump will not be of much use to you if
you don't know TCP.
2017-05-23 00:57:19 -07:00
Francois-Xavier Le Bail
d84904a156 Travis CI: Regenerate the Coverity Scan token 2017-05-17 17:54:24 +02:00
Francois-Xavier Le Bail
53cba91186 M3UA: Fix a typo 2017-05-11 15:56:08 +02:00
Francois-Xavier Le Bail
93a10559e7 PPP: Fix a typo 2017-05-11 15:32:43 +02:00
Francois-Xavier Le Bail
002cd31413 BGP: Fix a Coverity warning
The warning was:
Calling fn_printn without checking return value (as is done elsewhere
57 out of 58 times).
2017-05-05 09:39:43 +02:00
Job Snijders
d041d4f78e BGP: This patch accommodates for two bugs
1) the condition where the shutdown communication length field
   claims to be longer then the BGP NOTIFICATION Cease message
   actually can accomodate.

2) if the shutdown communication payload contains \0 (NUL) we
   should be able to print that rather then stop printing the
   string.
2017-05-03 18:33:48 +02:00
Job Snijders
edf4c90c34 Add support to decode a BGP Shutdown Communication
The draft-ietf-idr-shutdown-07 document specifies a mechanism to
transmit a short free form UTF-8 [RFC3629] message as part of a Cease
NOTIFICATION message [RFC4486] to inform the peer why the BGP session is
being shutdown or reset.

Hat tip to Peter van Dijk <peter.van.dijk@powerdns.com>
2017-04-17 14:46:38 +02:00
Denis Ovsienko
9c4af7213c Fixup the previous commit.
Add a comment about a minor nit and squelch a compiler warning:

./tcpdump.c:1104:4: warning: implicit declaration of function
'sysctlbyname' is invalid in C99
      [-Wimplicit-function-declaration]
                        sysctlbyname(sysctl, parent, &s, NULL, 0);
2017-04-02 21:45:56 +00:00
Rui Paulo
c1bb8784ab On a FreeBSD system when using tcpdump -I -i wlanN and wlanN is not a
monitor mode VAP, tcpdump will print an error message saying rfmon is
not supported.

Give a concise explanation as to how one might solve this problem by
creating a monitor mode VAP.
2017-04-02 21:42:54 +01:00
Steven H. Wang
99f6d01b24 add NSH ethertype
https://tools.ietf.org/html/draft-ietf-sfc-nsh-12#section-12.1
2017-04-02 09:08:17 +01:00
Francois-Xavier Le Bail
8cf42af454 Remove an unnecessary semicolon 2017-03-20 20:31:59 +01:00
Denis Ovsienko
9868446b1a Fixup -C for file size >2GB (GH #488).
Make Cflag long because that's the return type of pcap_dump_ftell().
2017-03-19 00:22:17 +00:00
Denis Ovsienko
d51a28aa3d update PLATFORMS 2017-03-15 11:35:56 +00:00
Denis Ovsienko
c6a993a4a3 LISP: include local netdissect.h first
This doesn't fix any known issue, just for consistency with all other
decoders.
2017-03-12 10:07:42 +00:00
Denis Ovsienko
78b09321e1 Travis CI: reduce git clone depth 2017-03-12 07:41:11 +00:00
Denis Ovsienko
f45dac2e17 list CONTRIBUTING in INSTALL.txt 2017-03-06 11:58:12 +00:00
Guy Harris
6311dc0b6e Printers MUST (not MAY or even SHOULD) check bounds. 2017-02-17 13:51:51 -08:00
Guy Harris
1ee088bde3 Update a comment. 2017-02-17 13:51:08 -08:00
Denis Ovsienko
913133dd1f update CREDITS 2017-02-09 12:58:33 +00:00
Denis Ovsienko
73b4862e21 update PLATFORMS 2017-02-09 12:42:50 +00:00
Guy Harris
5d3c5151c2 Don't close a pcap_t until we're done with its error buffer. 2017-02-06 15:28:50 -08:00
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