Commit Graph

98 Commits

Author SHA1 Message Date
Guy Harris
944a5e22aa Don't use leftover string length values.
Before processing an SMB request or response, set the string length
variable to 0, and set a flag indicating whether we *have* a string
length variable to "false".  Set the latter to "true" only if we
explicitly set the string length, and if it's not set when we process a
counted string, report an error.  (That *shouldn't* happen, but *can*
happen in a malformed packet, such as an NT Create AndX request with a
zero word count, meaning "no word parameters" and thus "no string length
word parameter".)
2019-05-22 09:15:34 -07:00
Guy Harris
14d771164d Set the protocol name to "smb" when dissecting SMB. 2019-05-18 14:54:06 -07:00
Guy Harris
f9c2c905b1 Squelch more narrowing warnings.
Add an ND_BYTES_BETWEEN() macro that computes how many bytes are
present, starting at the second argument and running up to (but not
including) the first argument, and returns that as a u_int (cutting it
to 32 bits on LP64 and LLP64 platforms).

Use that, including using it as a replacement for SMB's PTR_DIFF().
2019-04-18 11:01:55 -07: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
e65c17147a SMB: Avoid an unsigned integer underflow 2019-03-09 21:20:04 +01:00
Francois-Xavier Le Bail
a5211097d0 Remove some useless spaces 2019-02-01 13:59:45 +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
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
e2982e7f6f Update ND_PRINT() as a variadic macro 2018-01-07 13:36:41 +01:00
Guy Harris
39a7d38ee8 Clean up signed vs. unsigned.
Use unsigned for lengths.  Add additional length checks, as we can no
longer cheat and rely on "underflow turns the length negative, so just
check for > 0".

Show most NBT and SMB numerical fields as unsigned, as that's what they
are.  Have "d" and "D" treat the value as signed; add "u" and "U" for
unsigned values.
2018-01-06 22:18:00 -08:00
Francois-Xavier Le Bail
d488edcccc SMB: Address a clang warning
The warning was:
./print-smb.c:28:15: warning: no previous extern declaration for non-static
      variable 'startbuf' [-Wmissing-variable-declarations]
const u_char *startbuf = NULL;
              ^
2017-12-30 21:40:58 +01:00
Francois-Xavier Le Bail
1af717b1ac SMB: Add two missing bounds checks 2017-12-18 13:01:43 +01:00
Francois-Xavier Le Bail
41dbcba30b Use more the EXTRACT_U_1() macro (57/n) 2017-12-16 21:35:08 +01:00
Francois-Xavier Le Bail
b01cc24ce4 Simplify some expressions 2017-12-16 20:46:46 +01:00
Francois-Xavier Le Bail
6bb65331a5 Use more the EXTRACT_U_1() macro (53/n)
Assignment, p[n], (more)
2017-12-10 11:40:35 +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
451ac4c753 Use more the ND_TCHECK_1() macro 2017-12-04 21:00:57 +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
4166458a2a Use more the EXTRACT_U_1() macro (46/n)
In: if (... p[n] ...) ...
2017-12-03 21:51:36 +01:00
Francois-Xavier Le Bail
10a52254ae Use more the EXTRACT_U_1() macro (44/n)
In: switch (... p[n] ...) ...
2017-12-03 14:00:15 +01:00
Francois-Xavier Le Bail
61c422a88c Use more the EXTRACT_U_1() macro (43/n)
In: if (... p[n] ...) ...
2017-12-03 13:35:26 +01:00
Francois-Xavier Le Bail
a5bb53dd74 Simplify some expressions 2017-12-03 11:13:27 +01:00
Francois-Xavier Le Bail
e83dfd9b16 Simplify some expressions
This will also help some future scripted code updates.
2017-12-02 20:52:22 +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
39c8c55aa9 Use more ND_TCHECK_n()/ND_TTEST_n() macros 2017-11-24 22:48:55 +01:00
Francois-Xavier Le Bail
f68c3e3ec0 Use pointer expressions like in most similar cases 2017-11-23 12:23:32 +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
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
Guy Harris
ecf6e822e1 Do bounds checks on NBNS resource types and resource data lengths. 2017-01-18 09:16:40 +01:00
Guy Harris
97d372ef70 Before fetching the flags2 field, make sure we have it.
Also, don't fetch it until we need it, so we can do a little more
dissection before reporting a truncated packet.
2017-01-18 09:16:40 +01:00
Francois-Xavier Le Bail
ca54d72376 Declare some variables as static 2016-09-11 21:45:26 +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
817bdfede2 Rename print_data() to smb_print_data() 2015-09-18 13:04:24 +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
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
bf93670b6c Separate SMB-over-TCP output from TCP output with a space. 2014-10-19 13:58:20 -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
430631e5df SMB: make use of tok2str() and ternary conditional 2014-04-14 11:40:51 +04:00
Denis Ovsienko
bcf0fb3b48 NDOize SMB decoder 2014-04-02 08:14:19 +04:00
Denis Ovsienko
dbfdf97bde justify min()/max() macros declarations and usage
This change moves the macros to tcpdump-stdinc.h to make sure these are
available without interface.h. It also dismisses two redundant macros
MIN() and SMBMIN(). It is intended to fix the following Solaris compile
error:

Undefined                       first referenced
 symbol                             in file
MIN                                 print-zeromq.o
2014-03-14 09:55:30 +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
d8acd8f5d0 make consistent use of the "tstr" idiom
For each decoder that has more than one instance of truncation signaling
and prints the same string in each instance make sure that the string is
declared as "static const char tstr[]" right after the initial includes
block. Where necessary, replace fputs(s, stdout) with equivalent
printf("%s", s).
2013-12-26 18:19:50 +04:00