Commit Graph

5617 Commits

Author SHA1 Message Date
Denis Ovsienko
dcf83034e0 Update the date in tcpdump.1.in.
[skip ci]
2019-04-11 20:35:52 +01:00
Francois-Xavier Le Bail
0610a7cff2 IS-IS: Simplify some expressions 2019-04-09 22:50:41 +02:00
Francois-Xavier Le Bail
eafdbf764b ISOCLNS: Replace printf by ND_PRINT even when "#if 0"ed-out 2019-04-09 09:20:09 +02:00
Francois-Xavier Le Bail
c36abfe8a8 IS-IS: Fix some loops for undefined behavior at runtime
Same bugfixes than in previous commit, based on a code inspection.

Update the output of a test accordingly.

Moreover:
Clean up whitespaces/indentation.
2019-04-08 19:36:13 +02:00
Francois-Xavier Le Bail
fed13fc486 IS-IS: Fix a loop for undefined behavior at runtime
The error was:
print-isoclns.c:2822:7: runtime error: unsigned integer overflow:
4 - 6 cannot be represented in type 'unsigned int'

Update the output of a test accordingly.

Moreover:
Clean up whitespaces/indentation.
2019-04-08 17:23:53 +02:00
Francois-Xavier Le Bail
cc82ffa44f Ethernet: Rename a printer
Rename ether_print_hdr_len() to ether_hdr_len_print(), with _print
suffix like in most similar cases.
2019-04-03 20:59:41 +02:00
Guy Harris
db2c996e9c
Merge pull request #743 from taghos/master
Add shortcuts for setting time stamp precision
2019-04-03 11:17:30 -07:00
Guy Harris
e6b28d9d94 Explain why we're defining HAVE_REMOTE before including pcap.h. 2019-04-03 11:10:26 -07:00
Francois-Xavier Le Bail
de707da02a BRCMTAG: Prefer symbolic name than value 2019-04-03 15:46:57 +02:00
Francois-Xavier Le Bail
157a191052 Clean up whitespaces/indentation 2019-04-03 15:46:57 +02:00
Francois-Xavier Le Bail
968561fa1d Clean up whitespaces/indentation 2019-04-03 15:13:31 +02:00
Francois-Xavier Le Bail
1095f1011a DNS: Rename a printer
Rename ns_nprint() to fqdn_print(), with _print suffix like in most
similar cases.

Moreover:
Move a misplaced comment.
2019-04-03 14:38:07 +02:00
Ricardo Nabinger Sanchez
371e1fca31 Add shortcuts for setting time stamp precision
Add two shortcuts (as long-options) for setting the time stamp
precision: --micro and --nano.  While adding these options, reshuffle
the usage message to group up the options related to time stamp, and
removing the macro TIME_STAMP_PRECISION_USAGE.

If setting the time stamp precision is not supported by the available
libpcap, the usage won't mention these options (including
--time-stamp-precision), but they will still be presented in the
manpage.
2019-04-03 08:34:41 -03:00
Francois-Xavier Le Bail
dec3c3e848 OSPFv3: Add/remove some bounds checks
Remove two bounds checks now useless with GET_ macros uses.
The check on 'lshp->ls_router' is needed before ipaddr_string() call.
2019-04-02 15:38:43 +02:00
Francois-Xavier Le Bail
89c54d9bda Remove a trailing space 2019-04-02 14:24:17 +02:00
Francois-Xavier Le Bail
cf2a949169 Remove parameters names in functions declarations
As in most similar cases.
2019-03-31 15:04:57 +02:00
Francois-Xavier Le Bail
3fc59aec36 Fix some warnings
The warnings were:
implicit declaration of function 'malloc' [-Wimplicit-function-declaration]
incompatible implicit declaration of built-in function 'malloc'
implicit declaration of function 'free' [-Wimplicit-function-declaration]
incompatible implicit declaration of built-in function 'free'
2019-03-31 12:02:23 +02:00
Guy Harris
6da51b3ec9 Introduce a buffer stack, and use it for ESP decryption.
If a dissector has to process its input - decryption, decompression,
etc. - rather than dissect the raw input, it should push the processed
input onto the buffer stack.  As soon as the dissection is done, the
stack should be popped, to free the buffer into which the processing was
done, and restore the "pointer to packet data" and "pointer to end of
packet data" members of the netdissect_options structure, so the code
can go back to dissecting the original data.

The stack will get everything popped off it when dissection is done.

Use this mechanism in the ESP decryption code rather than scribbling on
top of the input packet data.
2019-03-30 19:26:06 -07:00
Guy Harris
3d9ae63197 Remove "ptr" from the names of pointers into the packet.
The IV pointer is just called iv in esp_print_decrypt_buffer_by_ikev2();
do the same in esp_print().  Rename ctptr to match.
2019-03-30 19:10:27 -07:00
Guy Harris
ada17ed496 Clean up code a bit.
"ivoff" is a pointer to the IV, not the offset of the IV; call it ivptr.

Have a variable that points to the beginning of the ciphertext, and use
that.

Fix the check that makes sure the authentication data/integrity check
value length isn't too big - it needs to make sure that it doesn't go
before the beginning of the ciphertext, i.e. doesn't overlap with the
IV.

Don't bother with a variable pointing to the secret, just pass
sa->secret.

Fix the check that makes sure the padding length isn't too big - make
sure it, plus 2 for the padding length and next header bytes, isn't
bigger than the ciphertext length.

Update a test to reflect the stricter length checks.
2019-03-30 18:08:02 -07:00
Guy Harris
fefd7f527f Clean up the check to make sure we can get the next header field.
Just check whether the pointer to it is within the available packet data
- and, if it's not, report truncation.

While we're at it:

Make the initialization vector length unsigned; it's either zero or a
positive number.

Rename a variable used for the ciphertext len to ctlen.
2019-03-29 16:16:46 -07:00
Guy Harris
a0ac048cf8 Check the return values of set_cipher_parameters() and EVP_Cipher(). 2019-03-29 12:40:20 -07:00
Guy Harris
b0acedad18 Don't hand un-decrypted data to the IP demuxer.
If we can't decrypt the payload, we can't dissect it, so don't try -
just give up immediately.

While we're at it:

If EVP_CIPHER_CTX_new() fails, it means a memory allocation failed;
treat that as such.

Use some of the arguments we're passed rather than re-fetching them from
the IP header.

Add some comments.

Call nd_print_trunc() for failed length sanity checks, and note that
they can fail due to the decryption being done with the wrong key.

Update one test's output; it is, I think, being decrypted with the wrong
key.
2019-03-29 10:52:58 -07:00
Ahmed Abdelsalam
a87d6a0448 Fix checksum calculation for IPv6 Segment Routing (SRv6) traffic
The checksum calculation for IPv6 packets is based on a pseudo
header that includes the packet's final Destination Address (DA).

If the IPv6 packet contains a Routing header, the final DA is the
last element of the Routing header [RFC8200].

Currently, tcpdump supports Routing header types 0 and 2.

IPv6 Segment Routing Header (SRH) is a new Routing header type (4).
SRH is defined in draft-ietf-6man-segment-routing-header [1].

This patch fix the checksum calculation for SRv6 packets. It allows
tcpdump to get the final DA value from SRv6 packets.

[1] https://tools.ietf.org/html/draft-ietf-6man-segment-routing-header-17
2019-03-29 12:04:21 +01:00
Guy Harris
7fbec6b880 Add a length check. 2019-03-28 14:30:33 -07:00
Guy Harris
48644533f2 Have esp_print() handle printing its payload.
That cleans things up a bit, including removing some duplicate code.

Clean up some other things, and add a length check, while we're at it.
2019-03-28 11:45:43 -07:00
Francois-Xavier Le Bail
400643120a IEEE 802.15.4: Fix an undefined behavior at runtime
The error was:
print-802_15_4.c:442:9: runtime error: implicit conversion from type
'int' of value 15840046 (32-bit, signed) to type 'uint16_t' (aka
'unsigned short') changed the value to 45870 (16-bit, unsigned)

Proposal of fix by Guy Harris:
"Those shifted values will be converted (in the C abstract machine) to
int, but they'll all be in the range 0 to 65535, as will be the XOR of
all 4 of them; converting that to a uint16_t isn't undefined behavior."
2019-03-28 14:13:27 +01:00
Francois-Xavier Le Bail
f280b3c0df Travis CI: Use Linux Xenial 2019-03-28 13:33:40 +01:00
Guy Harris
202051bb55 Put IPv4/IPv6 protocol demultiplexing into a common routine.
That means less duplication of functionality - and less chance that
XXX-over-IPv4 will be handled but XXX-over-IPv6 won't be handled, or
*vice versa*.  (CARP and VRRP were being handled over IPv4 but not over
IPv6; this fixes that.)
2019-03-27 19:58:26 -07:00
Guy Harris
b8964b5f43 Fix VRRP test.
We no longer print the source and destination IP addresses twice; update
the test output file.
2019-03-27 18:37:27 -07:00
Guy Harris
34ded09f84 No need to print the source and destination IP addresses twice on the same line. 2019-03-27 18:04:12 -07:00
Francois-Xavier Le Bail
088fa517bd RADIUS: Remove a now unused label 'trunc' 2019-03-27 14:15:15 +01:00
Francois-Xavier Le Bail
c9321fdee3 RADIUS: Remove an invalid bounds check now useless
Found by Bill Fenner with OSS-Fuzz.
2019-03-27 13:10:50 +01:00
Francois-Xavier Le Bail
751efec727 BRCMTAG: Fix terminating two "struct tok" arrays
Found by Bill Fenner with OSS-Fuzz.
2019-03-27 10:23:27 +01:00
Guy Harris
69128db28e Fix typo in comment.
[skip ci]
2019-03-26 19:52:36 -07:00
Guy Harris
0eec2bd464 Squelch a compiler warning.
Response codes are unsigned; make the argument to ns_rcode() unsigned.
2019-03-26 17:54:39 -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
1af20c3adc Add the ndo parameter to some functions
This parameter will be needed at the next step.
2019-03-26 21:06:23 +01:00
Francois-Xavier Le Bail
176e182416 Apply the first step of the new way to fetch data with bounds checking
Add GET_{BE|HE|LE}_, GET_U_1, GET_S_1, GET_IPV4_TO_HOST_ORDER,
GET_IPV4_TO_NETWORK_ORDER macros and
get_{be|he|le}_, get_u_1, get_s_1, get_ipv4_to_host_order,
get_ipv4_to_network_order inline functions,
with setjmp/longjmp logic to do better and easier data fetch with
bounds checking.

Based on Guy Harris's idea and code.
2019-03-26 21:06:06 +01:00
Francois-Xavier Le Bail
4154778a26 RX: Fix a data fetch
The serviceId field is 2 bytes long, therefore use EXTRACT_BE_U_2 to
fetch it.
2019-03-26 18:56:47 +01:00
Francois-Xavier Le Bail
8d35d75892 ZEP: Use nd_print_protocol() and nd_print_trunc() calls
Moreover:
Add a 'summary' comment with the protocol name.
2019-03-26 12:23:09 +01:00
Francois-Xavier Le Bail
ad92d9ae65 Remove useless comments 2019-03-26 10:07:34 +01:00
Francois-Xavier Le Bail
3bd3d8fb72 Clean up whitespaces 2019-03-26 08:56:20 +01:00
Francois-Xavier Le Bail
3d349d3558 IEEE 802.15.4: Fix two loops for undefined behavior at runtime
The errors were:
print-802_15_4.c:433:17: runtime error: unsigned integer overflow: 0 - 1
cannot be represented in type 'u_int' (aka 'unsigned int')
print-802_15_4.c:483:17: runtime error: unsigned integer overflow: 0 - 1
cannot be represented in type 'u_int' (aka 'unsigned int')
2019-03-25 22:19:14 +01:00
Michael Richardson
10dd76aef1 Merge branch 'kivinen-master' 2019-03-24 09:09:26 +01:00
Michael Richardson
35a1310799 Merge branch 'master' of https://github.com/kivinen/tcpdump into kivinen-master 2019-03-24 09:05:06 +01:00
Michael Richardson
2319e2892f
Merge pull request #733 from marka63/dns-get-extended-rcode
Extract extend DNS rcode from OPT record.
2019-03-23 10:32:00 -04:00
Denis Ovsienko
acb9b1c7ee Travis CI: Use ccache and parallel make. 2019-03-22 07:09:27 +00:00
Francois-Xavier Le Bail
dc8f136aff Travis CI: Add debug infos
Add a folded 'cat Makefile' (without the mkdep part for autotools).
Add a folded 'cat config.h'.
Add a folded 'cat config.log' (for autotools).

The 'sleep 10' command is a workaround for a display problem on osx.
2019-03-21 16:41:44 +01:00
Francois-Xavier Le Bail
e96aba9a90 LMP: Fix a loop for undefined behavior at runtime
The error was:
print-lmp.c:1132:13: runtime error: unsigned integer overflow: 249 - 516
cannot be represented in type 'unsigned int'

Update the output of a test accordingly.
2019-03-20 21:29:00 +01:00