Commit Graph

111 Commits

Author SHA1 Message Date
Francois-Xavier Le Bail
e2982e7f6f Update ND_PRINT() as a variadic macro 2018-01-07 13:36:41 +01:00
Francois-Xavier Le Bail
21aff56b39 FR: Add parentheses when extracting the flags
Should fix Coverity CID 1426919.
2017-12-23 12:20:37 +01:00
Francois-Xavier Le Bail
b04ee9c12e FR: Rework extracting the flags
Moreover:
Rename parse_q922_addr to parse_q922_header
2017-12-17 14:22:14 +01:00
Francois-Xavier Le Bail
e835e6a934 Fix spaces 2017-12-17 13:12:36 +01:00
Francois-Xavier Le Bail
e74cccfe79 FR: Fix extracting the DE flag
Update the output of a test accordingly.
2017-12-17 12:34:13 +01:00
Francois-Xavier Le Bail
1a04b92e36 Use more the ND_TTEST_1() macro 2017-12-15 19:39:00 +01: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
07ac438e08 Use more the EXTRACT_U_1() macro (52/n)
Assignment, p[n]
2017-12-09 14:05:25 +01:00
Francois-Xavier Le Bail
1cfd6cd2ac Use more the EXTRACT_U_1() macro (51/n)
Moreover: Use more the ND_ISPRINT() macro.
2017-12-09 11:46:15 +01:00
Francois-Xavier Le Bail
97de8ca7bd Use more the EXTRACT_U_1() macro (35/n)
In some safeputchar() calls, *(p).
2017-11-30 23:08:07 +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
a58370c17f Fix a bound check 2017-11-20 14:18:10 +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
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
1dcd10acea CVE-2017-12897/ISO CLNS: Use ND_TTEST() for the bounds checks in isoclns_print().
This fixes a buffer over-read discovered by Kamil Frankowicz.

Don't pass the remaining caplen - that's too hard to get right, and we
were getting it wrong in at least one case; just use ND_TTEST().

Add a test using the capture file supplied by the reporter(s).
2017-09-13 12:25:44 +01:00
Denis Ovsienko
26a4aa405a Frame Relay: denote a genuine fall through case
The source code comment explains it should fall through but GCC does not
pick it up, that's what the new macro is for.

./print-fr.c: In function ‘mfr_print’:
./print-fr.c:510:20: warning: this statement may fall through [-Wimplicit-fallthrough=]
                 if (ie_len == sizeof(struct timeval)) {
                    ^
./print-fr.c:521:13: note: here
             case MFR_CTRL_IE_VENDOR_EXT:
             ^~~~
2017-07-22 19:35:06 +01:00
Denis Ovsienko
c39c1d99ac CVE-2017-5482/Q.933: add a missing bounds check
Brian Carpenter had found that regardless of CVE-2016-8575 q933_print()
still could overread the buffer trying to parse a short packet. This
change fixes the problem.
2017-01-18 09:16:41 +01:00
Denis Ovsienko
857ec6e800 pass correct caplen to other functions as well
In ethertype_print(), isoclns_print() and snap_print() adjust the length
arithmetics along the same lines as for ether_print() in the previous
commit. Where done, the current pointer is not greater than snapend so
that the difference (i.e. caplen) is never negative.

This does not fix a reported issue but the problem was very likely to be
there.
2017-01-18 09:16:41 +01:00
Guy Harris
6bc44295cf CVE-2016-7985,7986/Change the way protocols print link-layer addresses.
If a protocol that runs under a link-layer protocol would print the
link-layer addresses for the packet as source and destination addresses
for the packet, don't have it blithely assume those link-layer addresses
are present or are at a particular offset from the beginning of that
protocol's data; Ethertypes, for example, are used by a number of
protocols, not all of which have Ethernet headers and not all of which
have any MAC headers.

Instead, pass the printers for those protocols structures with a pointer
to the address data and a pointer to a routine that prints the address.

Fixes some heap overflows found with American Fuzzy Lop by Hanno Böck.
2017-01-18 09:16:36 +01:00
Guy Harris
273a1a713b Clean up "invalid IE" messages. 2016-09-24 12:06:51 -07:00
Guy Harris
976a6d42dd Fix indentation. 2016-09-24 11:54:32 -07:00
Guy Harris
b32585658d Check for invalid IE lengths.
Also fix a failure to stop printing on error, and rename a routine to
reflect that it's used for codesets 0 and 5.
2016-09-21 18:18:19 -07:00
Guy Harris
547ad06362 More cleanups of Q.933 output. 2016-09-21 02:34:24 -07:00
Guy Harris
262417a225 Clean up printing of Q.933 packets.
Check the packet length and the snapshot length as we parse the packet.
Extract each field as we go.

Support arbitrary call reference lengths, 0 to 15 octets.

Handle single-octet IEs correctly - don't look for a length.

Handle both locking and non-locking shifts correctly.  Don't assume that
the first octet after the message type is a shift and contains a
codeset.  We were doing that, meaning that we tended to think codeset 1
was being used (by misparsing an IE with a code of 0x51 as a shift to
codeset 1) when it wasn't - codeset 0 was being used; correctly handle
codeset 0.
2016-09-21 01:57:55 -07:00
Guy Harris
5397ac8e9d The name is "FRF.15", so include the "." in the truncation message. 2016-09-20 02:08:13 -07:00
Guy Harris
db62bcccac Make another never-negative variable an unsigned.
It's assigned a u_int value, and printed with %u, so make it a u_int.
2016-09-20 02:02:06 -07:00
Guy Harris
e175de6b8c Make a never-negative variable a u_int.
That also lets us eliminate a cast.
2016-09-20 02:00:55 -07:00
Guy Harris
9e1b64c138 Fix incorrect length check. 2016-09-20 01:49:00 -07: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
45a212f0a2 Squelch a signed vs. unsigned comparison warning.
uint8_t + int constant = int; make the constant unsigned.
2016-04-13 18:57:09 -07:00
Guy Harris
cc79646a9d Add some packet-length checks. 2016-02-12 16:14:35 -08: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
Guy Harris
59864b113d Clean up printing of LLC packets.
Don't print LLC header information for SNAP packets; if we have a SNAP
header, just call snap_print() and return its return value, regardless
of whether it's 1 or 0, don't fall into the code to print raw LLC header
information - and don't print it with -e, either.

If llc_print() returns 0, just call the default packet printer, don't
print the MAC-layer header or the extracted ethertype - llc_print() will
print the source and destination MAC addresses and whatever type
information is in the LLC or SNAP headers.

If we don't know the DSAP/LSAP, and it's an information frame (numbered
or not) and not an XID frame, return 0, so that we give a hex dump of
the raw payload.

In addition, print the length when printing SNAP header information with
-e.
2015-04-17 18:38:46 -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
60a835d80f clean K&R style up in function declarations a bit
The function body should have its opening brace on the next line.
2015-03-05 10:35:03 +00:00
Guy Harris
e5b3ec43d3 Clean up bounds checking.
Fix link-layer header length for Cisco-style encapsulation while we're
at it.
2014-12-19 12:13:15 -08:00
Guy Harris
a6f81d534d Leave it up to ip6_print() to handle non-IPv6-capable systems.
Always define and declare ip6_print(), always compile print-ip6.c, and
always call it if we recognize a payload as IPv6.  If INET6 isn't
defined, ip6_print() will just print the length and note that printing
isn't supported.

That way, we don't do weird dissection of IPv6 packets on systems
without IPv6 support, due to, for example, ethertype_print() returning 0
("not dissected") for IPv6 packets on those systems (IPv6-over-Frame
Relay was dissected weirdly due to this).
2014-10-01 15:32:11 -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
8863fc0e5d NDOize some generic code 2014-04-03 17:43:33 +04:00
Denis Ovsienko
fc6f112b40 NDOize LLDP, PPP and RSVP decoders 2014-04-02 18:22:28 +04:00
Denis Ovsienko
51670d1949 NDOize safeputs() and safeputchar() 2014-04-01 19:46:05 +04:00
Denis Ovsienko
2210a967cb NDOize ISO CLNS decoder 2014-03-28 14:08:48 +04:00
Denis Ovsienko
979fc38d03 make use of ND_DEFAULTPRINT() 2014-03-26 18:52:40 +04:00
Denis Ovsienko
bed843855d NDOize Frame Relay, LMP and RADIUS decoders 2014-03-18 16:30:50 +04:00