Commit Graph

77 Commits

Author SHA1 Message Date
Francois-Xavier Le Bail
94a3708f00 Include <config.h> unconditionally
Builds using Autotools or CMake generate config.h, thus remove the
'#ifdef HAVE_CONFIG_H'/'#endif'.

Remove also the 'add_definitions(-DHAVE_CONFIG_H)' in CMakeLists.txt.
2024-03-28 05:34:34 +00:00
Francois-Xavier Le Bail
cc848f1535 Put "{" at end of line with "if" to keep a consistent style
[skip ci]
2023-04-19 22:03:12 +02:00
Francois-Xavier Le Bail
7d2bc7fcb5 Fix some typos
[skip ci]
2022-07-04 14:03:15 +02:00
Francois-Xavier Le Bail
d90dda7ef6 Fix some typos
[skip ci]
2020-12-12 16:10:46 +01:00
Francois-Xavier Le Bail
1b69d2a8a1 Replace the (void)nd_printzp() calls by nd_printjnp() calls 2020-12-10 20:34:09 +01:00
Denis Ovsienko
c754d30dbd STP: Modernize packet parsing style.
Remove all ND_TCHECK*() instances because they are redundant. Let
nd_printzp() guard the snapshot end. Report invalid packets as invalid,
not truncated. Make functions that always return the same value void.
ND_TCHECK_BRIDGE_ID() is not used anymore, so remove it. Update a test.
2020-12-09 23:54:10 +00: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
Francois-Xavier Le Bail
888210eb1c STP: Remove blank lines in output
Update the output of a test accordingly.
2019-08-15 15:55:53 +02:00
Guy Harris
1ed63b5d06 Remove more old-compiler compensation.
We require an environment with a C99-compatible snprintf(), so we don't
need to work around older implementations.  Make the configuration
process fail if we don't have snprintf() and vsnprintf().

We require at least VS 2015, so we don't have to check for _MSC_VER >=
1400.  Make the build fail if we don't have at least VS 2015.

We apparently do, however, have to use __inline, as the VS 2015
documentation doesn't meaning plain old "inline".  Update a comment.
2019-08-08 23:21:35 -07:00
Francois-Xavier Le Bail
15a174be8e Add some needed '&' when using a nd_byte type array struct member ...
... with the ND_TCHECK_SIZE() macro.

The ND_TCHECK_SIZE() macro is defined by:
 #define ND_TCHECK_SIZE(p) ND_TCHECK_LEN(p, sizeof(*(p)))

Example (in print-pptp.c):
struct pptp_msg_sccrp {
[...]
	nd_byte     hostname[64];
[...]
}

nd_byte is defined in netdissect.h:
typedef unsigned char nd_byte;

ptr is defined as: struct pptp_msg_sccrp *ptr.

As pointer values, ptr->hostname and &ptr->hostname are the same. Thus
the first parameter of ND_TCHECK_LEN() is the same with or without '&'.

When doing:
ND_TCHECK_SIZE(ptr->hostname);
The sizeof(*(p)) gives sizeof(*(ptr->hostname)),
Thus sizeof(unsigned char) is 1.
The check is wrong.

When doing:
ND_TCHECK_SIZE(&ptr->hostname);
The sizeof(*(p)) gives sizeof(*(&ptr->hostname)),
Thus sizeof(unsigned char [64]) is 64.
The check is right.

Thus, when using ND_TCHECK_SIZE with a nd_byte type array struct member,
we need the '&'.

This change revert partially 1b081ef03b.
2019-06-07 16:09:57 +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
Francois-Xavier Le Bail
1af20c3adc Add the ndo parameter to some functions
This parameter will be needed at the next step.
2019-03-26 21:06:23 +01:00
Francois-Xavier Le Bail
15ad390859 Add a nd_print_trunc() call
Update the output of some tests accordingly.
2018-05-17 13:59:05 +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
56e6581c34 Remove useless comments 2018-03-19 15:16:32 +01: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
c499612a7f Add nd_{v}snprintf() routines/wrappers.
Some versions of the MSVC runtime library have a non-C99-compliant
vsnprintf(), which we want to avoid.  On Windows, use snprintf() and
vsnprintf() for VS 2015 and later, where they both exist in
C99-compliant forms, and wrap _{v}snprintf_s() otherwise (they're
guaranteed to do the null termination that we want).
2018-01-29 15:48:55 -08:00
Francois-Xavier Le Bail
21f01bc6a6 STP: Replace ND_TCHECK call(s) by ND_TCHECK_SIZE call(s) 2018-01-23 16:59:51 +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
Francois-Xavier Le Bail
192f726d2a STP: Use more ND_TCHECK_n() macros 2018-01-07 21:51:55 +01:00
Francois-Xavier Le Bail
e2982e7f6f Update ND_PRINT() as a variadic macro 2018-01-07 13:36:41 +01:00
Guy Harris
ebd9266101 Use nd_ types, add EXTRACT_ calls, clean up signed vs. unsigned. 2017-12-30 18:37:50 -08: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
00b189d27c Use more the ND_TCHECK_1() macro 2017-12-04 17:50:29 +01:00
Francois-Xavier Le Bail
505cd1fe15 Use more the EXTRACT_U_1() macro (39/n)
In some macros and functions call, p[n]
2017-12-01 15:48:41 +01:00
Francois-Xavier Le Bail
415160c0c2 Use more ND_TCHECK_n() macros 2017-11-29 21:06:51 +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
d42f1df527 Use more the EXTRACT_U_1() macro to fetch a one-byte value (24/n)
In bittok2str() calls (step 3).
2017-11-23 15:23:12 +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
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
Francois-Xavier Le Bail
8d8f0953cd STP: Remove trailing spaces in output 2017-01-18 09:16:39 +01:00
Francois-Xavier Le Bail
5cb03afb57 STP: Filter out non-printable characters
Use fn_printzp().

Moreover:
Add a missing comma in output.
Use ND_TCHECK_32BITS instead of ND_TTEST_32BITS.
Add a test for spb_bpduv4.pcap with verbose output.
2017-01-18 09:16:38 +01:00
Guy Harris
968776fbf5 CVE-2016-7940/Add a bunch of bounds checks, and fix some printing.
The bounds checks fix some heap overflows found with American Fuzzy Lop
by Hanno Böck.

Add some ND_TTEST_/ND_TCHECK_ macros to extract.h to simplify writing
bounds checks for code that uses the other macros in that file.

Fix the printing of the SPB BPDU agreement digest - I don't think the
intent was to print the value of the first 4 bytes, that value + 4, that
value + 8, etc., I suspect it was to print the first 4 bytes, the next 4
bytes, etc..
2017-01-18 09:16:37 +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
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
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
d57e945e5e NDOize EIGRP, ICMP, L2TP, STP and UDP decoders 2014-03-15 23:25:06 +04:00
Denis Ovsienko
69f6f4392a don't include addrtoname.h needlessly 2014-02-25 17:53:08 +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
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