Commit Graph

108 Commits

Author SHA1 Message Date
Viral Mehta
955e4a763b print verifier cookie for write and commit operation 2018-09-05 10:55:08 +01:00
Guy Harris
19671cc62f Use nd_uint types for structures used to overlay packets. 2018-06-22 17:19:18 -07:00
Guy Harris
279bd14fc5 Clean up processing of RPC request header.
Don't just blast through it and do a single check at the end to make
sure we didn't run past the end of the packet; check for the
fixed-length part of the credentials, then check for the variable-length
part of the credentials, and then do the same two steps for the
verifier.

Fix the checks against the on-the-network length while we're at it.
2018-06-22 15:28:10 -07: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
Francois-Xavier Le Bail
0ee15606e2 Remove unneeded '&' when getting a pointer to a nd_ipv6 type 2018-01-31 16:43:50 +01:00
Francois-Xavier Le Bail
5922b80797 Remove unneeded '&' when getting a pointer to a nd_ipv4 type 2018-01-31 16:43:50 +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
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
aa023de590 NFS: Use more ND_TCHECK_n() macros 2018-01-24 11:09:25 +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
224629731a NFS: Use more ND_TTEST_n() macros 2018-01-21 19:44:42 +01: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
f252fd6aea Remove unneeded '&' when getting a pointer to an nd_uintN_t type 2018-01-11 23:06:48 +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
8b89eb8f6b NFS: Use more the ND_TCHECK_4() macro 2017-12-24 13:21:21 +01:00
Guy Harris
811063b60d Add comments explaining why using EXTRACT_BE_U_4() isn't wrong.
When showing a readdir verifier, using big-endian means that it shows
the verifier as a string of 16 octet values, from the first to the last,
which makes sense, and which means that the way we display it is
independent of the byte order of the host running tcpdump, which is a
Good Thing.

When showing a file handle, the same applies, although one could make a
case for not separating the 4-octet words with colons, and just showing
it as a sequence of octets.
2017-12-17 22:53:56 -08:00
Francois-Xavier Le Bail
9113e560eb NFS: Use more the EXTRACT_BE_U_4 macro 2017-12-17 09:30:00 +01:00
Guy Harris
e18798ad05 Use EXTRACT_BE_U_4() to fetch a 4-byte big-endian value from a packet. 2017-12-16 00:34:12 -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
93bee24026 Use pointer expressions like in most similar cases 2017-11-20 22:58:59 +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
6151e2190b NFS: Rename two printer functions
Their names must end with '_print'
2017-11-16 13:59:17 +01:00
Guy Harris
9aa08721e7 NFS: Check for all relevant RPC call body fields at the beginning.
If we don't have the procedure number, we'll give up eventually; might
as well give up before we do any work that'll be thrown away.
2017-09-13 12:25:44 +01:00
Francois-Xavier Le Bail
b45a9a167c CVE-2017-13005/NFS: Add two bounds checks before fetching data
This fixes a buffer over-read discovered by Kamil Frankowicz.

Add a test using the capture file supplied by the reporter(s).
2017-09-13 12:25:44 +01:00
Guy Harris
7a923447fd CVE-2017-13001/NFS: Don't copy more data than is in the file handle.
Also, put the buffer on the stack; no reason to make it static.  (65
bytes isn't a lot.)

This fixes a buffer over-read discovered by Kamil Frankowicz.

Add a test using the capture file supplied by the reporter(s).
2017-09-13 12:25:44 +01:00
Guy Harris
19d25dd878 CVE-2017-12898/NFS: Fix bounds checking.
Fix the bounds checking for the NFSv3 WRITE procedure to check whether the
length of the opaque data being written is present in the captured data,
not just whether the byte count is present in the captured data.
furthest forward in the packet, not the item before it.  (This also lets
us eliminate the check for the "stable" argument being present in the
captured data; rewrite the code to print that to make it a bit clearer.)

Check that the entire ar_stat field is present in the capture.

Note that parse_wcc_attr() is called after we've already checked whether
the wcc_data is present.

Check before fetching the "access" part of the NFSv3 ACCESS results.
This fixes a buffer over-read discovered by Kamil Frankowicz.

Include a test for the "check before fetching the "access" part..." fix,
using the capture supplied by the reporter(s).
2017-09-13 12:25:44 +01:00
Francois-Xavier Le Bail
ca54d72376 Declare some variables as static 2016-09-11 21:45:26 +02:00
Francois-Xavier Le Bail
12857bf113 Improve code readability: A pointer should not be compared to zero
Using Coccinelle script badzero.cocci
2016-08-25 09:48:49 +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
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
Guy Harris
5fc3681a13 Don't assume the ONC RPC header is nicely aligned.
Use UNALIGNED_MEMCPY() to extract the XID from it; otherwise, this might
crash on machines that require strict alignment (e.g., SPARC machines).

Fixes GitHub issue #478.
2015-08-24 18:14:55 -07: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
f2b690e8b5 Don't assume the NFS request is aligned on a 4-byte boundary.
The XID is a multi-byte field, and, if it's not aligned, it must be
copied with UNALIGNED_MEMCPY().

This should fix GitHub issue #395.
2014-06-25 12:55:25 -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
Denis Ovsienko
330c159e07 NFS: prepend %x format with 0x (mitigates GH #35) 2014-04-15 12:43:47 +04:00
Denis Ovsienko
24598ce6b7 NDOize the rest of util.c 2014-04-14 10:53:46 +04:00
Denis Ovsienko
1a105f1e18 NFS: use tok2str() 2014-04-13 19:47:55 +04:00
Denis Ovsienko
d6a7593fd9 remove unused function nfsreq_print() 2014-04-11 18:31:40 +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
5d6a1edd06 NDOize NFS decoder 2014-04-01 16:05:33 +04:00