Commit Graph

4426 Commits

Author SHA1 Message Date
Guy Harris
f76e7feb41 CVE-2017-12896/ISAKMP: Do bounds checks in isakmp_rfc3948_print().
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
Denis Ovsienko
a1eefe9860 CVE-2017-13687/CHDLC: Improve bounds and length checks.
Prevent a possible buffer overread in chdlc_print() and replace the
custom check in chdlc_if_print() with a standard check in chdlc_print()
so that the latter certainly does not over-read even when reached via
juniper_chdlc_print(). Add length checks.
2017-09-13 12:25:44 +01:00
Ulrich Windl
071190f7a9 tests/TESTonce: More verbose failure message
Add the reason for not executing a test and the status if the command
exited with a non-zero status.
2017-09-12 20:37:26 -07:00
Guy Harris
0d8f07921a Clean up pcap_findalldevs() call to find the first interface.
If it returns -1, it's an error; report the error.

If it returns 0, but the list is empty, that's not an error in
pcap_findalldevs(); report it explicitly as "no interfaces available for
capture".
2017-09-09 10:39:50 -07:00
Herwin Weststrate
df13dce54d Added RADIUS attributes from RFC7155
Originating Line Info (94)
2017-09-07 20:48:59 +01:00
Herwin Weststrate
e398c5f1bf Added RADIUS attributes from RFC4849
NAS Filter Rule (92)
2017-09-07 20:48:59 +01:00
Guy Harris
c724af9222 MSVC doesn't allow __declspec(noreturn) to be applied to function pointers. 2017-09-06 11:02:15 -07:00
Denis Ovsienko
19961761ae Travis CI: enable fast_finish
This will signal the build failure as soon as any job has failed
(libpcap has this enabled already).
2017-09-06 11:11:44 +01:00
Denis Ovsienko
74e12dfb8d AppleTalk: Address a few cppcheck style notices.
[print-atalk.c:283]: (style) The scope of the variable 'c' can be
reduced.
[print-atalk.c:380]: (style) The scope of the variable 'c' can be
reduced.
[print-atalk.c:360]: (style) Variable 'c' is assigned a value that is
never used.
2017-09-06 09:58:36 +01:00
Denis Ovsienko
eb02553274 ForCES: Fix undefined behaviour in op_valid().
[print-forces.c:316] -> [print-forces.c:323]: (warning) Shifting 32-bit
value by 32767 bits is undefined behaviour. See condition at line 323.
[print-forces.c:316]: (error) Shifting by a negative value is undefined
behaviour
2017-09-06 00:52:57 +01:00
Denis Ovsienko
2dfa645e86 ForCES: Fixup a cppcheck style notice.
[print-forces.c:281]: (style) Checking if unsigned variable 'opt' is
less than zero.
2017-09-06 00:31:29 +01:00
Denis Ovsienko
2c1666e522 syslog: squelch a cppcheck warning (GH #568)
[print-syslog.c:98]: (style) Array index 'msg_off' is used before limits
check.

Even though this is a false positive in this specific case, let's not
have it around, this will make it less likely missing a real one.
2017-09-05 23:03:21 +01:00
Denis Ovsienko
80deba151a NTP: Add missing bounds checks.
This change adds checks that were missing from the recent NTP code and
could cause a buffer over-read vulnerability (see earlier commits for
rationale).
2017-09-04 12:40:36 +01:00
Denis Ovsienko
0dd013253d NTP: Update length checks after the recent commit.
Rename NTP_MSG_MINLEN to NTP_TIMEMSG_MINLEN for clarity and introduce and
use NTP_CTRLMSG_MINLEN. With this change ntp_control_print() can detect
invalid packets better.
2017-09-04 12:31:26 +01:00
Denis Ovsienko
60128eebca NTP: Use nd_XXXXX integer types in the structures.
This prevents alignment issues when the structures are used to access
the input buffer (see earlier commits for more detailed rationale).
2017-09-04 12:31:20 +01:00
Denis Ovsienko
febd0bc5aa NTP: Use tstr for truncation indicator.
This implements the same convention as in all other decoders.
2017-09-04 12:30:20 +01:00
Ulrich Windl
c2e2a18f27 print-ntp.c: Handle NTP Control Messages
In print-ntp.c:
Rename struct ntpdata into struct ntp_time_data and add new
struct ntp_control_data to map NTP Control messages.

Add figure of NTP Control Message Header as comment.

Add union ntpdata to provide a common view on NTP messages.

Rename ntp_print() to ntp_time_print(), using new structures.
Improve comment and re-arrange fields in ntp_print().

Add ntp_control_print() to handle NTP Control Messages.
Output R, E, M, OpCode, Sequence, Status, Assoc, Offset, and Count in
ntp_control_print().

A new ntp_print() will decode only the very basics (VN, LI and Mode)
to call ntp_time_print() or ntp_control_print(), depending on Mode.
2017-09-04 11:52:16 +01:00
Guy Harris
c78c621010 Squelch a warning.
poll() is a system API on UN*Xes, so calling a variable "poll" causes
"declaration of 'poll' shadows a global declaration" warnings in some
compilers.  Call the argument "poll_interval" instead.
2017-09-04 00:42:14 -07:00
Guy Harris
8dda56aa5a We also turn of *all* protocol name resolution with -n. 2017-09-03 12:12:23 -07:00
Denis Ovsienko
069b2e3920 Mention more changes for the future 4.9.2 release. 2017-09-03 12:12:42 +01:00
Guy Harris
7039327875 CVE-2017-11543/Make sure the SLIP direction octet is valid.
Report if it's not, and don't use it as an out-of-bounds index into an
array.

This fixes a buffer overflow discovered by Wilfried Kirsch.

Add a test using the capture file supplied by the reporter(s), modified
so the capture file won't be rejected as an invalid capture.
2017-09-02 21:36:44 +01:00
Guy Harris
21d702a136 CVE-2017-11541: In safeputs(), check the length before checking for a NUL terminator.
safeputs() doesn't do packet bounds checking of its own; it assumes that
the caller has checked the availability in the packet data of all maxlen
bytes of data.  This means we should check that we're within the
specified limit before looking at the byte.

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

Add a test using the capture file supplied by the reporter(s).
2017-09-02 21:36:44 +01:00
Guy Harris
bed48062a6 CVE-2017-11542/PIMv1: Add a bounds check.
This fixes a buffer over-read discovered by Kamil Frankowicz.

Add a test using the capture file supplied by the reporter(s).
2017-09-02 21:36:44 +01:00
Denis Ovsienko
e40c0ca2d9 Add a section for future 4.9.2 release to CHANGES. 2017-09-02 21:36:44 +01:00
Guy Harris
6f0750ee0c Make the ESP decryption not crash with OpenSSL 1.1.
While we're at it, free the cipher context if we fail to allocate the
output buffer for decryption.
2017-09-01 04:00:38 -07:00
Guy Harris
0d2cdb5dad The cipher context must be initialized before we can get the block size. 2017-08-31 00:03:59 -07:00
Guy Harris
a02b7aa397 Report *all* non-zero exit codes from the tcpdump command.
That will report, for example, exit code 139, which is issued for
SIGSEGV crashes.
2017-08-30 21:53:12 -07:00
Guy Harris
1e5cac716f Count the complex tests correctly, and pick up the counts correctly. 2017-08-30 21:36:24 -07:00
Guy Harris
a9ec709f70 Count the complex tests as passed or failed. 2017-08-30 21:10:41 -07:00
Guy Harris
f7e20cf4da Cleanups.
Attempt to allocate the buffer before doing any decryption calls and, if
the attempt fails, report an error and return an error indication.

Make sizes unsigned, as they can't be negative;
EVP_CIPHER_CTX_block_size() returns an int, but that's just because they
picked the wrong data type in OpenSSL.

No need to use calloc() for the output buffer - just use malloc().
2017-08-30 11:18:32 -07:00
Denis Ovsienko
0559dc9874 NTP: Improve length checks.
In ntp_print() add a missing length check to reject packets that are
declared too short, make the existing length checks easier to follow and
add a catch-all block after the known message layouts.

This fixes a bug where an invalid packet could be erroneously printed
like it is valid so long as the provided buffer was large enough. That
said, the bounds checks were done correctly so there was no over-read.
2017-08-30 13:53:56 +01:00
Miroslav Lichvar
bd3f9392a6 Print NTP MAC with 160-bit digest.
An NTP packet authenticated with a key using stronger hash function than
MD5 may have a 160-bit digest.
2017-08-30 12:57:17 +01:00
Guy Harris
dcf755f49b Get rid of an unneeded variable.
We don't want to try to suppress warnings about discarding the const
qualifier, as that's something we need to fix.  Adding the extra
variable doesn't suppress it on some platforms, so it's not useful
there, and if it does suppress it, we don't want that.

And we weren't doing it in the other case, anyway.

Comment in both cases with an XXX comment about the cast.
2017-08-29 15:05:00 -07:00
Guy Harris
8205015f71 Get rid of another unused variable. 2017-08-29 14:55:44 -07:00
Guy Harris
884b1b45c8 Get rid of unused variable. 2017-08-29 14:54:50 -07:00
Guy Harris
c70c7b5d21 Merge pull request #613 from msehnout/master
Use separate buffers for encrypted and decrypted content
2017-08-29 11:33:37 -07:00
Guy Harris
0f44948df5 Update print-esp.c 2017-08-29 11:32:18 -07:00
Guy Harris
2d861fb1a7 Update print-esp.c 2017-08-29 11:31:20 -07:00
Guy Harris
b19c83b54e Update print-esp.c 2017-08-29 11:29:26 -07:00
Ulrich Windl
99412d6d5a Print NTP timestamps as UTC, not local time
print-ntp.c: Change p_ntp_time() to print NTP timestamps in UTC instead
of local time.  This allows for consistent output for automatic testing
different time zones.  Also use an ISO 8601 (RFC3339) format for the
time stamps.
2017-08-29 14:47:51 +01:00
Ulrich Windl
1136bb5c53 Prepare print-ntp.c for NTP Control Messages
Add shift constants LEAPSHIFT(6) and MODESHIFT(0).
Rename MODE_RES1 to MODE_CONTROL, adjusting ntp_mode_values[].
2017-08-29 14:46:03 +01:00
Ulrich Windl
b1ee9bac52 print-ntp.c: Add and use VERSIONSHIFT
Add shift constant VERSIONSHIFT(3), and use it in ntp_print().
2017-08-29 14:45:24 +01:00
Ulrich Windl
8cdb42601b Improve comment for tok2str() in util-print.c 2017-08-29 14:44:35 +01:00
Denis Ovsienko
688ac7b668 NTP: For clarity use 0x with hexadecimal format. 2017-08-29 12:03:05 +01:00
Miroslav Lichvar
a4ea3caa57 Fix printing of NTP key-id.
The key-id in an NTP MAC is in big-endian format.
2017-08-29 12:42:10 +02:00
Miroslav Lichvar
d729c670fc Print NTP refid as hexadecimal number.
In NTPv4 (RFC 5905) the refid field for stratum > 1 is an IPv4 address
or first 32 bits of MD5 sum of an IPv6 address. It's not possible to
tell which of the two it actually is. Print the field as a hexadecimal
number in order to not confuse refids generated from IPv6 addresses with
IPv4 addresses.
2017-08-29 12:37:58 +02:00
Miroslav Lichvar
63c8c04ea7 Fix printing of NTP poll interval.
The poll value in an NTP packet is a signed integer. For negative values
print the interval as a fraction of second. Also, ignore values outside
of interval (-32, 32).
2017-08-29 12:37:58 +02:00
Martin Sehnoutka
f3c52ca01e Use separate buffers for encrypted and decrypted content in print-esp.c
The EVP_Cipher function should not be called with the same buffer as
input and output. It works fine on most architectures, but fails on
PowerPC. There is also a second problem, that we write the output to a
const buffer, but this issue is not addressed with this PR.
2017-08-29 10:04:35 +02:00
Denis Ovsienko
2f7c41dda8 Fixup the previous commit. 2017-08-27 21:11:43 +01:00
Denis Ovsienko
b3fb6a6c61 Use a table instead of getprotobynumber().
On Linux getprotobynumber() returns different results for the same
argument depending on the contents of /etc/protocols at runtime
(expectedly but gets in the way of reproducible test cases). On FreeBSD
it returns results that are irrelevant of the contents of /etc/protocols
at runtime (unexpectedly). Other implementations exist and may expose
interesting properties too. And if the host uses LDAP instead of
/etc/protocols for name services, a call to that function may cause LDAP
handle the request. All of the above is not right for the specific task
of network protocols decoding, which needs to be fast and deterministic.

As the protocol number space is just 8-bit, add a 256-element array of
strings/NULLs for the translation and a wrapper function around it for
index range enforcement. Change the code to use the new function instead
of getprotobynumber().

Fix a typo while at it.
2017-08-27 14:19:25 +01:00