Andrea Ieri [Sun, 16 Dec 2018 12:13:58 +0000 (13:13 +0100)]
Amend the documentation about the use of the -C -G and -W switches.
When using all three switches (-C -G and -W), the behavior is
practically identical to only using -C and -G, as the -W flag will only
affect the filename suffix.
Guy Harris [Tue, 11 Dec 2018 07:16:45 +0000 (23:16 -0800)]
Add, and use, macros to do locale-independent case mapping.
This means we get the same behavior in Turkish locales (where, if we
aren't in the C locale, we might get lower-case "i" mapped to upper-case
"I with dot" and upper-case "I" mapped to lower-case "i without dot),
and may also suppress some shortening warnings from MSVC.
We may just want to suppress the warning, as in "trust us, we know what
we're doing", although it'd be nice if the format string passed to those
functions could be checked to make sure it is one that takes exactly one
integer argument.
Guy Harris [Tue, 11 Dec 2018 05:53:58 +0000 (21:53 -0800)]
Try to squelch a warning about non-constant format strings.
Declare the format-string argument to tok2strbuf(), tok2str(),
bittok2str(), and bittok2str_nosep() as such, to see whether that gets
MSVC not to complain - or if it just gets upset because there's no "..."
argument list for it.
Guy Harris [Tue, 11 Dec 2018 04:14:57 +0000 (20:14 -0800)]
Squelch a warning.
We're returning the calculated checksum result modulo 65536, given that
Internet checksums are 16-bit; throw in a cast to let MSVC know that
this is intended.
Guy Harris [Wed, 21 Nov 2018 23:09:39 +0000 (15:09 -0800)]
Change tests/hoobr_bfd_print.pcap to test the BFD printer again.
Clamp the on-the-wire length values of the packets at 262144, so that we
hand the packets to the BFD printer, rather than just bailing out before
we ever get there.
The sanity check in print.c/pretty_print_packet() function, packet length
(length) >= capture length (caplen), apply when the ether_print()
function is called by ether_if_print(), netanalyzer_if_print() or
netanalyzer_transparent_if_print().
But the ether_print() function is called in some other cases, thus not
sure length always >= caplen.
Guy Harris [Tue, 13 Nov 2018 06:03:49 +0000 (22:03 -0800)]
Fix printing of Linux cooked captures with monitor-mode packets.
Apparently, if you have an interface in monitor mode, capturing on the
"any" device can get packets that have a SLL hatype of 803, which is the
ARPHRD_ value for radiotap, and with the payload containing a radiotap
header, followed by an 802.11 header, followed by the 802.11 payload.
Handle that.
Francois-Xavier Le Bail [Sun, 11 Nov 2018 20:39:25 +0000 (21:39 +0100)]
DCCP: Fix some undefined behaviors at runtime
The errors were like:
print-dccp.c:448:4: runtime error: unsigned integer overflow: 20 - 24
cannot be represented in type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior print-dccp.c:448:4
Guy Harris [Fri, 9 Nov 2018 20:00:59 +0000 (12:00 -0800)]
Require sys/capsicum.h to use Capsicum.
My PC-BSD 9.1 VM, at least, has sys/capability.h but not sys/capsicum.h;
we now use sys/capsicum.h, so require it to be present (which it is in
FreeBSD 10 and later).
Guy Harris [Fri, 9 Nov 2018 19:33:55 +0000 (11:33 -0800)]
Require sys/capsicum.h to use Capsicum.
My PC-BSD 9.1 VM, at least, has sys/capability.h but not sys/capsicum.h;
we now use sys/capsicum.h, so require it to be present (which it is in
FreeBSD 10 and later).
Guy Harris [Sun, 14 Oct 2018 05:51:54 +0000 (22:51 -0700)]
Fix nd_snprintf(buf, buflen, "string");
If this is VS prior to 2015 or MinGW, we can't trust snprintf(); we have
to use _snprintf_s(), but that requires us to insert _TRUNCATE as an
argument after the buffer and buffer length and before the format string
and arguments, if any, to the format string.
That means we need to use a vararg macro; however, if we make the format
string a regular argument to the macro, that means that, if there are no
arguments *after* the format string, you end up with an argument list to
_snprintf_s() that ends with "fmt, ", and that's not valid C.
*If* we knew this was GCC or Clang, we could use a GNU C-specific hack,
wherein, if __VA_ARGS__ is preceded by ## and there's a comma before
that, the comma is removed if __VA_ARGS__ is empty, but this might be
Microsoft's C compiler in a version of Visual Studio prior to VS 2015,
which might not support that.
So we have to just have the macro take, as the ... arguments, the format
string and its arguments.
Guy Harris [Tue, 18 Sep 2018 07:07:24 +0000 (00:07 -0700)]
Reorganize the dissection code a bit.
Get rid of the global nfserr variable and, instead, have it be local to
interp_reply(). That means one less global variable, which may be good
if any multi-threaded program tries to use libnetdissect in more than
one thread (there are still global variables that would have to be
removed), and gets rid of some cases where we didn't need to set it.
Don't bundle multiple operations inside an if clause. This squelches
some warnings from MSVC, and makes the code a bit more uniform and a bit
easier to understand (and, in the process of doing that, found a bug
that was fixed in 596aca3d9384e739961df0b5c9ffd9d8161d6c9b).
Guy Harris [Fri, 14 Sep 2018 02:19:38 +0000 (19:19 -0700)]
See if a newer MSVC will produce fewer warnings.
Some of the narrowing warnings are false positives; newer versions of
Clang do a better job than older ones of determining the range of values
of expressions, and don't warn if the range is such that it can be
safely narrowed, so maybe the same is true of MSVC.
Guy Harris [Thu, 6 Sep 2018 03:26:39 +0000 (20:26 -0700)]
Don't assume ARM supports unaligned accesses.
Prior to ARMv6, it didn't support it. ARMv6 supports it, if the "don't
act like ARMv5" bit isn't set in the system control register, but has
another bit in the system control register to cause unaligned accesses
to fault rather than succeed. ARMv7 and later don't have "act like
ARMv5" mode, but still has the "fault on unaligned access" bit.
At least some OSes might set the "fault on unaligned access" bit; if
your OS *doesn't* set it, feel free to modify the #if to check for your
OS and for ARM.
Guy Harris [Wed, 5 Sep 2018 19:04:03 +0000 (12:04 -0700)]
Remove trailing "_if" from protocol names.
"_if", in function names, is just a convention used for the top-level
routine for a given DLT_ value; it's not part of the protocol name for
the link-layer type.