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".)
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().
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.
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.
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.
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
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
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.
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.
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
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.
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).