Commit Graph

118 Commits

Author SHA1 Message Date
Francois-Xavier Le Bail
3ed92cd021 Replace the (void)nd_printn(..., NULL) calls by nd_printjn() calls
Moreover:
Remove a now useless comment.
2021-01-08 17:12:12 +01:00
Denis Ovsienko
375b9ff7b6 BOOTP: Modernize packet parsing style.
Enable ND_LONGJMP_FROM_TCHECK. Report invalid packets as invalid. Have
nd_printn() and nd_printztn() guard the snapshot end. Replace
client_fqdn_flags() with bittok2str_nosep().
2021-01-08 03:23:53 +00:00
Denis Ovsienko
ea0d29f743 Spell most remaining MAC_ADDR_LEN instances. [skip ci] 2020-10-04 13:36:48 +01:00
Bill Fenner
fab90c5c95 Update for messages and TLVs defined in RFC4388 2020-09-23 10:17:30 +00:00
Francois-Xavier Le Bail
aad6ac30ce Remove some now redundant ND_TCHECK_4() calls
ND_TCHECK_4(e).

They are redundant because they are followed by a GET_IPADDR_STRING(e)
call, same e, which do the bounds check.

Remove unused 'trunc' labels and associated codes.

Update the output of a test accordingly.
2020-09-08 14:14:13 +02:00
Denis Ovsienko
51e180c4fb Remove 96 assorted ND_TCHECK calls.
Remove a number of instances that do not match common patterns and have
the only substantial effect on the code flow that a truncated packet
triggers "goto trunc" instead of longjmp(). (In a few cases this change
can increase the number of fields printed before giving up.)
2020-09-08 05:04:58 +01:00
Francois-Xavier Le Bail
abc8c2d61c Remove many (762) now redundant ND_TCHECK_n() calls
ND_TCHECK_n(e), n in { 1, 2, 3, 4, 8 }.

They are redundant because they are followed by a GET_.*_n(e) call,
same n, same e, which do the bounds check.

Remove unused 'trunc' labels and most associated codes.

Update the outputs of some tests accordingly.
2020-09-06 20:22:29 +02:00
Denis Ovsienko
34ec5e5f3f DHCP: Make option printing format more consistent.
rfc1048_print() used to print DHCP options in a few different formats
depending on the context (see GH issue #866):

* at the top of an RFC 1048 block:
  * known options: [string] name and [decimal] tag
  * unknown options: tag twice
* inside a Parameter Request (55) block:
  * known options: name
  * unknown options: tag

Change it to use the "Name (tag)" format (as in TCP, BGP, etc) in all
contexts. Update output for 8 tests.
2020-08-07 19:04:31 +01:00
Denis Ovsienko
776ebde21a DHCP: Remove a few options that are unassigned now.
Commit e89bfcd in December 2000 among other things had introduced
the following code points from the IANA "BOOTP Vendor Extensions and
DHCP Options" registry:

* TAG_AGENT_MASK (84)
* TAG_6OVER4 (96)
* TAG_IPX_COMPAT (110)
* TAG_FAILOVER (115)
* TAG_EXTENDED_REQUEST (126)
* TAG_EXTENDED_OPTION (127)

The current revision of the registry lists every code above as
"Removed/Unassigned" with a reference to RFC 3679 published in January
2004. Remove the code points and any associated code.
2020-08-07 19:04:31 +01:00
Francois-Xavier Le Bail
2c377170bd DHCP: Harmonize error messages printing 2020-05-14 13:46:55 +02:00
Francois-Xavier Le Bail
e2481334a1 DHCP: Fix the option 81 flags field printing
The first nibble of the option 81 flags field must be zero.
The current flags are in the second nibble.

From RFC 4702:

2.1.  The Flags Field

   The format of the 1-octet Flags field is:

        0 1 2 3 4 5 6 7
       +-+-+-+-+-+-+-+-+
       |  MBZ  |N|E|O|S|
       +-+-+-+-+-+-+-+-+

[...]

   The remaining bits in the Flags field are reserved for future
   assignment.  DHCP clients and servers that send the Client FQDN
   option MUST clear the MBZ bits, and they MUST ignore these bits.
2020-05-14 13:46:55 +02:00
Guy Harris
306c2a0384 More bounds checking when fetching addresses and converting to strings.
Replace more calls to ipaddr_string()/ip6addr_string() with calls to
GET_IPADDR_STRING()/GET_IP6ADDR_STRING() macros performing bounds
checking.

Add similar bounds-checking inline functions and macros to wrap
linkaddr_string(), etheraddr_string(), and isonsap_string() and convert
calls to them to use the macros as well.

Shuffle the inline functions in addrtoname.h around a bit, so that the
inline functions, external declarations, and macros are all in the same
order.
2020-01-19 19:55:38 -08:00
Francois-Xavier Le Bail
8534f3b7bf Use more HTTPS in URLs
[skip ci]
2019-08-19 15:49:21 +02:00
Francois-Xavier Le Bail
1b081ef03b Remove some unneeded '&' when getting a pointer to a nd_ type
Moreover:
Remove some unneeded casts.
2019-04-21 20:21:06 +02:00
Francois-Xavier Le Bail
ee68aa3646 Use the new GET_ macros instead of the EXTRACT_ ones
The exceptions are currently:
Some EXTRACT_ in print-juniper.c, not used on packet buffer pointer.
An EXTRACT_BE_U_3 in addrtoname.c, not always used on packet buffer
pointer.
2019-03-26 21:06:24 +01:00
Denis Ovsienko
9ea3e1b265 Fix some spelling in comments.
[skip ci]
2018-08-01 14:06:33 +01:00
Guy Harris
202ad44712 Fix test for truncated sname and file.
nd_printztn() returns 0 if the string is truncated; check for it
returning zero, not for returning a non-zero value.

This fix was supplied in GitHub issue #685.
2018-06-21 14:54:02 -07:00
Francois-Xavier Le Bail
34017c6fcb Add a nd_print_trunc() call
Moreover:
Replace a ND_TTEST_*() with ND_TCHECK_*().
2018-05-18 14:01:47 +02:00
Francois-Xavier Le Bail
ba8936b39b Print truncations with nd_print_trunc() instead of tstr[] strings
Remove the tstr[] strings.
Update the output of some tests accordingly.

Moreover:
Add or update some ndo_protocol fields.
2018-05-04 13:47:49 +02:00
Francois-Xavier Le Bail
3e3e6d2ef4 Rename the fn_printX() functions to nd_printX()
The functions are: nd_print, nd_printztn, nd_printn and nd_printzp.
Trying to make it clearer that they currently have to be used only on part
of the packet buffer.
Update some comments.
2018-04-30 13:35:06 +02:00
Francois-Xavier Le Bail
546558eabd Add the ndo_protocol field in the netdissect_options structure
Update this field in printer entry functions.
It will be used for some printings.
2018-03-16 19:44:47 +01:00
Guy Harris
f727010777 Get rid of ND_UNALIGNED.
Structures that describe packet formats now all use nd_ types, none of
which require more than 1-byte alignment, so compilers shouldn't assume
that anything in those structures is aligned on any particular boundary,
even without a "this is unaligned" hint.
2018-02-14 14:03:41 -08:00
Francois-Xavier Le Bail
0002ff41f0 BOOTP: Use more ND_TCHECK_n() macros 2018-02-12 14:36:00 +01:00
Francois-Xavier Le Bail
46f5203a8d Style update
Use parens around the sizeof argument, to match the style used elsewhere.
2018-02-06 20:01:55 +01:00
Guy Harris
6babce0e17 Use nd_ipv4 rather than struct in_addr.
This ensures that we have no purportedly-aligned-but-not-necessarily-
unaligned values that we access; we have to use EXTRACT_ macros/functions
to get at IPv4 address values.
2018-01-30 14:39:15 -08:00
Francois-Xavier Le Bail
2a1c7a3975 BOOTP: Use more ND_TCHECK_n() macros 2018-01-22 20:34:35 +01:00
Guy Harris
45fc519a2a Don't test for __attribute__ in the configure script.
Instead, use compiler test macros to check whether *particular*
attributes are supported, and set various #defines appropriately, in
header files.

Rename the UNALIGNED structure attribute to ND_UNALIGNED, and ask
whether we still need it.
2018-01-21 17:57:20 -08:00
Guy Harris
fb2479d733 Always include <config.h> rather than "config.h".
This can prevent bizarre failures if, for example, you've done a
configuration in the top-level source directory, leaving behind one
config.h file, and then do an out-of-tree build in another directory,
with different configuration options.  This way, we always pick up the
same config.h, in the build directory.
2018-01-21 12:27:28 -08:00
Francois-Xavier Le Bail
513f782ae1 Use quoted include netdissect-stdinc.h instead of angle-bracketed one 2018-01-21 10:28:15 +01:00
Guy Harris
64677b0d78 Clean up signed vs. unsigned. 2018-01-11 11:52:30 -08:00
Francois-Xavier Le Bail
6475b3c8f0 BOOTP: Use more ND_TCHECK_n() macros 2018-01-07 21:01:13 +01:00
Francois-Xavier Le Bail
e2982e7f6f Update ND_PRINT() as a variadic macro 2018-01-07 13:36:41 +01:00
Francois-Xavier Le Bail
9c1556ca28 BOOTP: Fix parentheses errors
These errors were not previously detected because of the use of
the single argument, double parentheses ND_PRINT() macro.
2018-01-06 22:26:06 +01:00
Francois-Xavier Le Bail
f5eb55fa6d BOOTP: Move macro define/undef outsite functions
This avoid some Coccinelle warnings:
CPP-DEFINE: inside function, I treat it as comment
CPP-UNDEF: inside function, I treat it as comment

This also makes the code a bit clearer.
2018-01-04 17:20:19 +01:00
Guy Harris
85078eeaf4 Use nd_ types, add EXTRACT_, fix a bounds check. 2017-12-29 19:26:24 -08:00
Francois-Xavier Le Bail
5cea270318 Remove all storage class specifier 'register'
Let the compiler do the optimizations (or not) based on build options.

Avoid 'value has been optimized out' messages in gdb using '-O0'.
2017-12-13 19:17:47 +01:00
Francois-Xavier Le Bail
84ef17ac0e Replace ND_TTEST2()/ND_TCHECK2() macros by macros using pointers (1/n)
ND_TTEST2(var, l)  -> ND_TTEST_LEN(p, l)
ND_TCHECK2(var, l) -> ND_TCHECK_LEN(p, l)
2017-12-11 22:11:01 +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
Guy Harris
f411a05060 More EXTRACT_8BITS() changes. Use ND_CHECK_nBITS() more as well. 2017-11-19 17:59:51 -08:00
Francois-Xavier Le Bail
d1d01e3c0e Use more the EXTRACT_8BITS() macro to fetch a one-byte value (4/n)
In client_fqdn_flags() call.
2017-11-19 15:51:54 +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
29e5470e6a CVE-2017-13028/BOOTP: 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
3951a87cbe spell ASCII in uppercase 2017-08-10 09:52:46 +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
Guy Harris
7bf069c251 CVE-2016-7983,7984/Don't use strchr() to scan packet data.
It can't be told to stop at the end of the packet data.  Add a
fn_printztn() that prints null-terminated strings, with a length check,
and which returns the number of bytes processed, or 0 if we ran out of
data.  That means it does the scanning we need, but safely.

Use it in the TFTP and BOOTP printers.

Fixes a heap overflow found with American Fuzzy Lop by Hanno Böck.
2017-01-18 09:16:37 +01:00
Eliot Lear
3caf684848 Updated print-bootp.c with corrected options for TZ and added option for MUDURL.
Updated print-dhcpv6.c to process TZ options as well as MUDURL.
2016-12-08 14:18:24 +01: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
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
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