Commit Graph

56 Commits

Author SHA1 Message Date
Francois-Xavier Le Bail
763aa0b5f1 IPv6 mobility: Use more ND_TTEST_n() macros 2018-01-07 21:20:23 +01:00
Francois-Xavier Le Bail
e2982e7f6f Update ND_PRINT() as a variadic macro 2018-01-07 13:36:41 +01:00
Guy Harris
4ef2f8ba3a Use nd_ types, add EXTRACT_ calls. 2017-12-30 17:17:56 -08:00
Francois-Xavier Le Bail
6bb65331a5 Use more the EXTRACT_U_1() macro (53/n)
Assignment, p[n], (more)
2017-12-10 11:40:35 +01:00
Francois-Xavier Le Bail
00b189d27c Use more the ND_TCHECK_1() macro 2017-12-04 17:50:29 +01:00
Francois-Xavier Le Bail
4166458a2a Use more the EXTRACT_U_1() macro (46/n)
In: if (... p[n] ...) ...
2017-12-03 21:51:36 +01:00
Francois-Xavier Le Bail
61c422a88c Use more the EXTRACT_U_1() macro (43/n)
In: if (... p[n] ...) ...
2017-12-03 13:35:26 +01:00
Francois-Xavier Le Bail
e83dfd9b16 Simplify some expressions
This will also help some future scripted code updates.
2017-12-02 20:52:22 +01:00
Francois-Xavier Le Bail
dbcba20b5e Use more the EXTRACT_U_1() macro (42/n)
In: switch (... p[n] ...) ...
2017-12-02 00:04:55 +01:00
Francois-Xavier Le Bail
1a90fd99d2 Use more the EXTRACT_U_1() macro (28/n)
In ND_PRINT() macro call(s) (step 7).

p[n] ...
2017-11-26 15:44:43 +01:00
Francois-Xavier Le Bail
575188b5bf Use pointer expressions like in most similar cases 2017-11-25 18:21:18 +01:00
Francois-Xavier Le Bail
39c8c55aa9 Use more ND_TCHECK_n()/ND_TTEST_n() macros 2017-11-24 22:48:55 +01:00
Francois-Xavier Le Bail
f68c3e3ec0 Use pointer expressions like in most similar cases 2017-11-23 12:23:32 +01:00
Francois-Xavier Le Bail
da20bc56d6 Rename EXTRACT_ macros
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
2017-11-22 23:54:09 +01:00
Francois-Xavier Le Bail
3c8f3e13b0 Rename ND_TCHECK_/ND_TTEST_ macros
Now all the macros have a name meaning a count in bytes.

e.g.:
ND_TCHECK_32BITS -> ND_TCHECK_4
ND_TTEST_32BITS -> ND_TTEST_4
2017-11-22 21:58:44 +01:00
Francois-Xavier Le Bail
93bee24026 Use pointer expressions like in most similar cases 2017-11-20 22:58:59 +01:00
Francois-Xavier Le Bail
577621026d Rename EXTRACT_nBITS() macros to EXTRACT_BE_nBITS()
It indicates clearly that these macros are used to extract big-endian
integral values.
2017-11-18 13:56:40 +01:00
Francois-Xavier Le Bail
5338aac7b8 CVE-2017-13025/IPv6 mobility: Add a bounds check before fetching data
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 cause 'tcpdump: pcap_loop: truncated dump file'
2017-09-13 12:25:44 +01:00
Francois-Xavier Le Bail
7d3aba9f06 CVE-2017-13024/IPv6 mobility: Add a bounds check before fetching data
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 cause 'tcpdump: pcap_loop: truncated dump file'
2017-09-13 12:25:44 +01:00
Francois-Xavier Le Bail
b8e559afae CVE-2017-13023/IPv6 mobility: Add a bounds check before fetching data
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 cause 'tcpdump: pcap_loop: truncated dump file'
2017-09-13 12:25:44 +01:00
Denis Ovsienko
95cb8ad87a Fix Linux/GCC build after the previous commit.
ip6.h now needs netdissect.h, fix includes order where required to fix:

./ip6.h:181:2: error: unknown type name ‘nd_uint8_t’
  nd_uint8_t  ip6r0_nxt;  /* next header */
  ^
./ip6.h:182:2: error: unknown type name ‘nd_uint8_t’
  nd_uint8_t  ip6r0_len;  /* length in units of 8 octets */
  ^
./ip6.h:183:2: error: unknown type name ‘nd_uint8_t’
  nd_uint8_t  ip6r0_type;  /* always zero */
  ^
./ip6.h:184:2: error: unknown type name ‘nd_uint8_t’
  nd_uint8_t  ip6r0_segleft; /* segments left */
  ^
./ip6.h:185:2: error: unknown type name ‘nd_uint32_t’
  nd_uint32_t ip6r0_reserved; /* reserved field */
  ^
2017-09-13 12:25:44 +01:00
Guy Harris
db8c799f6d CVE-2017-13009/IPv6 mobility: Add a bounds check.
This fixes a buffer over-read discovered by Brian 'geeknik' Carpenter.

Add a test using the capture file supplied by the reporter(s).

While we're at it:

Add a comment giving the RFC for IPv6 mobility headers.

Clean up some bounds checks to make it clearer what they're checking, by
matching the subsequent EXTRACT_ calls or memcpy.

For the binding update, if none of the flag bits are set, don't check
the individual flag bits.
2017-09-13 12:25:44 +01:00
Guy Harris
66df248b49 CVE-2017-12985/IPv6: Check for print routines returning -1 when running past the end.
rt6_print(), ah_print(), and esp_print() return -1 if they run up
against the end of the packet while dissecting; if that happens, stop
dissecting, don't try to fetch the next header value, because 1) *it*
might be past the end of the packet and 2) we won't be using it in any
case, as we'll be exiting the loop.

Also, change mobility_print() to return -1 if it runs up against the
end of the packet, and stop dissecting if it does so.

This fixes a buffer over-read discovered by Brian 'geeknik' Carpenter.

Add tests using the capture files supplied by the reporter(s).
2017-09-13 12:25:44 +01:00
Francois-Xavier Le Bail
8cf42af454 Remove an unnecessary semicolon 2017-03-20 20:31:59 +01:00
Francois-Xavier Le Bail
90dc6cb575 IPv6 mobility: Fix printing of 'truncated' string
Moreover:
Fix spaces before tabs
2016-10-09 20:38:57 +02:00
Francois-Xavier Le Bail
11d3a01319 Move the printer summaries from INSTALL.txt to each printer
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
2016-08-14 17:03:43 +02:00
Guy Harris
11f73ad248 Don't require IPv6 library support in order to support IPv6 addresses.
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.
2015-09-17 14:56:44 -07:00
Francois-Xavier Le Bail
99c91c3aec Rename 'tcpdump-stdinc.h' to 'netdissect-stdinc.h'
Get the full log via: git log --follow netdissect-stdinc.h
2015-09-10 08:50:40 +02:00
Francois-Xavier Le Bail
b638c78b40 Remove obsolete comments 2015-09-07 15:01:46 +02:00
Francois-Xavier Le Bail
c1c3c77463 Printers must include 'netdissect.h', not 'interface.h' 2015-09-05 23:35:58 +02:00
Guy Harris
69cb46af91 Fix a bunch of de-constifications. 2015-04-26 17:24:42 -07:00
Denis Ovsienko
38700c7f24 dismiss NETDISSECT_REWORKED macro
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.
2015-03-22 10:06:15 +00:00
Denis Ovsienko
74851aac62 IPv6 mobility: make use of tok2str() 2015-03-13 20:07:32 +00:00
Denis Ovsienko
9eb8c3a296 IPv6 mobility: remove unused macros
Those were part of an earlier implementation of the protocol with a
different encoding. For the present encoding ip6m_hdrlen[] does the job.
2015-03-12 22:40:04 +00:00
Michael Richardson
192fabf4bd test case for cve2015-0261 -- corrupted IPv6 mobility header
Author:    Michael Richardson <mcr@sandelman.ca>
2015-03-10 23:15:50 -07:00
Guy Harris
a2633f2f21 More fixes for uint8_t being shorter than u_int8_t.
Fix a typo while we're at it.
2014-04-23 11:53:22 -07:00
Guy Harris
ed85e20e4d u_intN_t is dead, long live uintN_t.
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.
2014-04-23 00:20:40 -07:00
Guy Harris
1cde6435df Netdissectify the to-name resolution routines.
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.
2014-04-04 00:43:46 -07:00
Denis Ovsienko
17934c433e NDOize 7 bigger decoders
This change converts IGMP, IPv6 mobility options, LDP, Lightweight
Access Point, PGM, PPTP and RIP decoders.
2014-03-19 14:16:56 +04:00
Denis Ovsienko
3ea7a6988e IPv6: refresh options decoding (GH #47 pt. 3)
Brian Haley points that mobility (sub-)options decoded in
print-ip6opts.c are specific to draft-ietf-mobileip-ipv6 only. RFC3775
(and respectively RFC6275) uses different encoding and parameter space,
which print-mobility.c already handles.

Remove deprecated code and update some related macros.
2014-01-04 16:39:33 +04:00
Denis Ovsienko
fe3253b9b8 remove tcpdump's own CVS keywords
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.
2014-01-03 00:59:08 +04:00
Michael Richardson
a97fb2f3ae whitespace changes 2014-01-01 21:31:18 -05:00
Denis Ovsienko
57c538422b IPv6: use unsigned mobility vars (GH #47 pt. 2) 2013-12-19 18:02:29 +04:00
Denis Ovsienko
4ae4df98b2 IPv6: articulate %u printf format (GH #47 pt. 1)
All integers printed in decimal in print-mobility.c are unsigned.
Although there is no difference between %d and %u for 8/16-bit integers,
switch to %u for consistency.
2013-12-19 16:20:03 +04:00
guy
3968553431 Get rid of an unused variable. 2005-04-20 22:21:00 +00:00
guy
bbc1cfa669 Have the configure script arrange that the Makefile define _U_
appropriately, and that GNUmakefile and the MSVC++ project file define
it apppriately, as we do with libpcap, rather than defining it in
"interface.h".

Undo the rcsid-shuffling and addition of extra #includes, as we no
longer need to arrange that "interface.h" be included before using _U_
in an RCS ID or copyright.
2003-11-16 09:36:07 +00:00
guy
3824a6c041 From Neil Spring:
use "_U_" in the definitions of "rcsid[]", to eliminate
	complaints about those variables being unused;

	move the definitions after the include of "interface.h", or add
	an include of "interface.h", so that "_U_" is defined.

Include "config.h" before including "tcpdump-stdinc.h" in
"missing/datalinks.c".
2003-11-15 00:39:12 +00:00
guy
c243fe7be4 From Kazushi Sugyo: update to draft-ietf-mobileip-ipv6-20. 2003-02-05 02:36:25 +00:00
guy
fcc82f451d The "__attribute__((packed))" tag on structures causes some files not to
compile with Sun C, as "interface.h" isn't being included before the
structures are being declared.

Furthermore, in the files that Sun C *can* compile, it doesn't cause Sun
C to generate code that's safe with unaligned accesses, as
"__attribute__" is defined as a do-nothing macro with compilers that
don't support it.

Therefore, we get rid of that tag on the structures to which it was
added, and instead use "EXTRACT_16BIT()" and "EXTRACT_32BIT()" to fetch
16-bit and 32-bit big-endian quantities from packets.  We also fix some
other references to multi-byte quantities to get rid of code that tries
to do unaligned loads on platforms that don't support them.

We also throw in a hack that makes those macros use
"__attribute__((packed))" on structures containing only one 16-bit or
32-bit integer to get the compiler to generate unaligned-safe code
rather than doing it by hand.  (GCC on SPARC produces the same code that
doing it by hand does; I don't know if GCC on any other big-endian
strict-alignment processor generates better code for that case.  On
little-endian processors, as "ntohs()" and "ntohl()" might be functions,
that might actually produce worse code.)

Fix some places to use "%u" rather than "%d" to print unsigned
quantities.
2002-12-11 07:13:49 +00:00
guy
717587453c From Kazushi Sugyo: update to draft-ietf-mobile-ipv6-19.txt. 2002-11-13 09:35:51 +00:00