Commit Graph

78 Commits

Author SHA1 Message Date
Francois-Xavier Le Bail
acd0ac7443 OSPFv3: Remove two unnecessary dereferences
Remove also two unnecessary ND_TCHECK_SIZE().

Moreover:
Remove an unnecessary cast.
2022-02-18 20:05:35 +01:00
Guy Harris
f853e73acf Replace ND_TCHECK_/memcpy() pairs with GET_CPY_BYTES().
For BGP, this eliminates some cases where routines return -1 on
truncation; clean up after that.

This also means that some memcpy()s get replaced by UNALIGNED_MEMCPY(),
which may fix some issues on processors that don't support unaligned
accesses.
2021-01-05 18:08:50 -08:00
Francois-Xavier Le Bail
10ac942adc OSPFv3: Use %zu to print sizeof values
Moreover:
Fix indentation.
2020-11-04 16:28:36 +01:00
Denis Ovsienko
4f15e3afd1 OSPF6: Update the option bit props.
In the "OSPFv3 Router Properties Registry" the code point 0x08 is
deprecated and the code point 0x10 stands for Nt-bit, not N-bit. Also
list the N-bit from "OSPFv3 Options (24 bits)".
2020-10-02 20:01:20 +01: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
7ae1579954 Remove some now redundant ND_TCHECK_16() calls
ND_TCHECK_16(e).

They are redundant because they are followed by a GET_IP6ADDR_STRING(e)
call, same e, which do the bounds check.
2020-09-07 18:36:18 +02: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
Guy Harris
11e454d0ba ospf6: note some places where subtraction won't underflow. 2020-05-27 02:18:38 -07: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
179660e6a9 OSPFv3: Fix a bounds check
Moreover:
Clean up whitespaces/indentation.
2019-04-19 23:36:38 +02:00
Francois-Xavier Le Bail
dec3c3e848 OSPFv3: Add/remove some bounds checks
Remove two bounds checks now useless with GET_ macros uses.
The check on 'lshp->ls_router' is needed before ipaddr_string() call.
2019-04-02 15:38:43 +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
Francois-Xavier Le Bail
46efa1bc47 Fix spaces 2018-09-03 15:18:19 +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
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
Francois-Xavier Le Bail
ef987f720c Rename some printer functions to *_print
Moreover:
Fix spaces.
2018-02-22 14:19:42 +01:00
Francois-Xavier Le Bail
5dfebc9722 OSPFv3: More nd_ipv6-ification 2018-01-31 20:40:45 +01:00
Guy Harris
0dad1934af Have ip{6}addr_string take a u_char * as the second argument.
Fix warnings that introduces.
2018-01-31 00:43:45 -08:00
Guy Harris
398ef7f336 A bit more nd_ipv4-ification. 2018-01-30 17:30:54 -08:00
Guy Harris
3db38df8ed Use nd_ipv6 rather than struct in6_addr in packet-layout structures.
Also, use it, and nd_ipv4, in sizeof() operations.
2018-01-30 17:29:33 -08:00
Francois-Xavier Le Bail
5791511faa OSPFv3: Use more ND_TCHECK_n() and ND_TCHECK_SIZE() macros 2018-01-24 06:50:17 +01:00
Francois-Xavier Le Bail
6e15ad4b99 Use more ND_TCHECK_n() macros 2018-01-22 21:51:29 +01: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
e2982e7f6f Update ND_PRINT() as a variadic macro 2018-01-07 13:36:41 +01:00
Francois-Xavier Le Bail
d526e47658 Use ND_TTEST_SIZE()/ND_TCHECK_SIZE() macros (1/n) 2018-01-03 21:32:07 +01:00
Francois-Xavier Le Bail
ce4e690346 OSPFv3: Replace ND_TCHECK2 call by ND_TCHECK_LEN call 2017-12-14 22:41:15 +01:00
Guy Harris
41b9478cc8 Use nd_ types for OSPF and OSPF6 packets.
And add EXTRACT_ calls as required.

Remove no-longer-necessary & operators in EXTRACT_ calls.
2017-12-14 10:28:57 -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
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
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
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
d4aeb0e54a OSPFv3: More bounds checks. 2017-09-13 12:25:44 +01:00
Francois-Xavier Le Bail
88b2dac837 CVE-2017-13036/OSPFv3: 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 be rejected as an invalid capture.
2017-09-13 12:25:44 +01: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
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
Guy Harris
f149d769de Split the OSPFv3 header and bodies into separate structures.
Some compilers appear to put some padding before the ospf6_un union, so
the OSPFv3 packets aren't dissected correctly.  Pull the members of
that union into separate structures, and find the pointer to the OSPFv6
body by adding the header length to the pointer to the beginning of the
header.
2014-05-01 19:48:10 -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
20ecf8fafe Squelch a Coverity warning.
Make the lsa_p_prefix field as large as the largest possible prefix, so
that Coverity doesn't complain about going past the end of an array.
2014-04-18 17:43:09 -07:00
Denis Ovsienko
50905f4d0a OSPFv3: fix SEGV on SPARCv9 (concurs with 8f6bca3)
This bug arose on the OpenCSW build farm:

    ospf3_auth-vv                 : TEST FAILED

Dagobert Michelsen had helped to use the farm servers to debug.
2014-04-11 13:18:20 +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
Denis Ovsienko
2b753f8058 NDOize DECnet, OSPF and TCP decoders 2014-04-02 14:24:56 +04:00
Denis Ovsienko
b46194277a spell "%s" format strings (complements 708a68a)
Make "%s" format string always reside in the print function call
explicitly such that the reader doesn't have to assess its safety.
2014-03-31 15:43:22 +04:00