Commit Graph

35 Commits

Author SHA1 Message Date
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
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
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
Guy Harris
0cb1b8a434 CVE-2017-13688/OLSR: Do bounds checks before we fetch data.
While we're at it, clean up some other bounds checks, so we check that
we have a complete IPv4 message header if it's IPv4 and a complete IPv6
message header if it's IPv6.

This fixes a buffer over-read discovered by Bhargava Shastry,
SecT/TU Berlin.

Add tests using the capture files supplied by the reporter(s).
2017-09-13 12:25:44 +01:00
Hannes Gredler
ff8464bffd zero change: update Hannes Gredler's email 2017-07-28 17:44:12 +02:00
Francois-Xavier Le Bail
b38f324af9 Add a summary comment in all other printers
Moreover:
Remove some redundant comments
Update some summary comments
Update the specification URL for ATA over Ethernet (AoE) protocol
2016-08-15 22:42:38 +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
c1c3c77463 Printers must include 'netdissect.h', not 'interface.h' 2015-09-05 23:35:58 +02:00
Francois-Xavier Le Bail
568866ab38 Fix warnings as "ISO C90 does not support the '%lf' gnu_printf format"
The complete warnings were:
ISO C90 does not support the '%lf' gnu_printf format [-Wformat=]
2015-08-18 18:20:10 +02:00
Francois-Xavier Le Bail
9ba41b4da2 OLSR: Fix indent and comments
Avoid too long lines.
Not all C compilers accept C++/C99 comments by default.
2015-05-04 15:25:54 +02:00
Ferry Huberts
4b4106c93d olsr: fix printing of smart-gateway HNAs in IPv4
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
2015-05-03 17:30:47 +02:00
Ferry Huberts
d8b204e4e7 olsr: fix 'Advertised networks' count
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
2015-05-03 17:30:47 +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
Francois-Xavier Le Bail
07dfc4e1c4 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).
2014-12-08 22:18:16 +01:00
Guy Harris
4038f83ebf Do more bounds checking and length checking.
Don't run past the end of the captured data, and don't run past the end
of the packet (i.e., don't make the length variable go negative).

Also, stop dissecting if the message length isn't valid.
2014-11-11 16:49:39 -08:00
Denis Ovsienko
f0f2e6d058 don't reinvent ND_TCHECK2() 2014-06-12 14:59:03 +04: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
Denis Ovsienko
24598ce6b7 NDOize the rest of util.c 2014-04-14 10:53:46 +04: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
Gisle Vanem
a8ace2868c OLSR: work around MSVC preprocessor (re 48d8b05) 2014-04-03 09:35:14 +04:00
Denis Ovsienko
779bcfb73a convert some stray printf()'s 2014-04-02 18:55:50 +04:00
Denis Ovsienko
62a5184ed4 NDOize ForCES, MPLS LSP ping and OLSR decoders 2014-03-27 14:58:23 +04:00
Denis Ovsienko
ec3761518b justify MIN()/min() further (complements dbfdf97) 2014-03-15 23:31:48 +04:00
Michael Richardson
ac910c086e ndo-ize print-ascii: hex_print_with_offset() 2014-01-01 21:31:18 -05:00
Denis Ovsienko
7de355927b justify declarations of struct tok arrays
Make sure all of them are declared const and most of them -- static.
Proper declaration of token arrays is a common review point for new code
that is based on existing decoders. Thus fix the issue at its root.
2013-09-24 20:54:03 +04:00
Guy Harris
429c8b46ee Fix up length checking for the MID message to check before *each*
interface address, not just the *first* interface address.

For the name service message:

	add length checking, both against truncated packets and bogus
	lengths;

	use fn_printn to print the name, to protect against control
	characters, etc. in the name.
2009-06-28 12:16:43 -07:00
Guy Harris
57bc7f6ef5 Just use u_int, even for values that fit in 16 bits; that squelches a
(irrelevant, but true for the way C works) signed vs. unsigned
comparison warning.  It also probably produces better machine code.
2009-05-21 10:48:19 -07:00
Florian Forster
289e0aed7d print-olsr: Add basic IPv6 support.
Unfortunately OLSR uses the same IDs for IPv4 and IPv6 packets, even
though the size of "messages" differ. The version of the internet protocol
is therefore handed to the "olsr_print" function.

The code isn't very nice, due to a high density of #ifdef INET6'es. If
IPv6-support really should be optional, I'm afraid this is inevitable.
Both, compilation with and without IPv6 support has been tested.

The patch addresses fixes other issues, too. The length given in the packet
was used for pointer arithmetic without checking if the value was in a
reasonable range first in several places. It should now be possible to
decode more than one "namespace message" within a single packet. Other
changes remove trailing whitespace or fix lines indented with tabs (the
majority of the file is indented using spaces).

Signed-off-by: Florian Forster <octo@leeloo.lan.home.verplant.org>
2009-05-21 10:38:40 -07:00
Guy Harris
b0dc4a55ea Get rid of trailing whitespace. 2009-05-21 10:14:22 -07:00
Florian Forster
efb465c5a8 print-olsr: Don't trust the package payload.
Especially not to do pointer arithmetic.

This is a real problem even without malicious people around if you use
OLSR via IPv6, because the message IDs didn't change but addresses are
now longer than four bytes.

Signed-off-by: Florian Forster <octo@leeloo.lan.home.verplant.org>
2009-05-21 10:09:45 -07:00
hannes
c695e7fee4 add support for the nameservice plugin messages generated by www.olsr.org 2008-08-16 11:23:09 +00:00
hannes
1716c03cd7 add support for printing of tc,tc-lq,hello,hna and mid messages 2007-03-28 07:34:55 +00:00
hannes
cb08bf9e3e add basic skeleton for printing olsr packets as per rfc3626
add a line break in verbose mode fro the ip printer.
2007-03-27 10:44:09 +00:00