aboutsummaryrefslogtreecommitdiff
path: root/print-llc.c
diff options
context:
space:
mode:
authorPedro F. Giffuni <pfg@FreeBSD.org>2015-01-31 16:26:21 +0000
committerPedro F. Giffuni <pfg@FreeBSD.org>2015-01-31 16:26:21 +0000
commitd3b6650ba68c44e3a488aac17bbe56d0cd0e870d (patch)
tree372984dfa0bd4ecdc121d7d9fd2e6688438cad39 /print-llc.c
parentaae6b2073aeb7ba1118183bb52286e44dd04df28 (diff)
downloadsrc-d3b6650ba68c44e3a488aac17bbe56d0cd0e870d.tar.gz
src-d3b6650ba68c44e3a488aac17bbe56d0cd0e870d.zip
Upstream fixes for issues found with afl (Issue #417).
- Fix length checking. Check both the captured length and the on-the-wire length (the latter *should* be greater than or equal to the former, but that's not guaranteed). Add some additional length checks, so neither caplen nor length underflow. If we stop dissecting because the packet is too short, return 1, not 0, as we've "dissected" what we can; 0 means "this is LLC+SNAP with an OUI of 0 and an unknown Ethertype". commit: 743bcecdc92f88b118ec7aac4f68b606601205cc - Clean up length checks. Check only the amount of length that matters at any given point; yes, this means we do multiple checks, but so it goes. We don't need to check for LLC+SNAP - llc_print() does that for us. We do, however, need to check to make sure we can safely skip the Fore header. commit: 5c65e7532fa16308e01299988852b0dc5b027559
Notes
Notes: svn path=/vendor/tcpdump/dist/; revision=277981
Diffstat (limited to 'print-llc.c')
-rw-r--r--print-llc.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/print-llc.c b/print-llc.c
index e78378d05b5a..e8a3314c5c79 100644
--- a/print-llc.c
+++ b/print-llc.c
@@ -151,10 +151,10 @@ llc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
*extracted_ethertype = 0;
- if (caplen < 3) {
+ if (caplen < 3 || length < 3) {
ND_PRINT((ndo, "[|llc]"));
ND_DEFAULTPRINT((u_char *)p, caplen);
- return(0);
+ return (1);
}
dsap_field = *p;
@@ -177,10 +177,10 @@ llc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
* The control field in I and S frames is
* 2 bytes...
*/
- if (caplen < 4) {
+ if (caplen < 4 || length < 4) {
ND_PRINT((ndo, "[|llc]"));
ND_DEFAULTPRINT((u_char *)p, caplen);
- return(0);
+ return (1);
}
/*
@@ -240,6 +240,11 @@ llc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
if (ssap == LLCSAP_IP && dsap == LLCSAP_IP &&
control == LLC_UI) {
+ if (caplen < 4 || length < 4) {
+ ND_PRINT((ndo, "[|llc]"));
+ ND_DEFAULTPRINT((u_char *)p, caplen);
+ return (1);
+ }
ip_print(ndo, p+4, length-4);
return (1);
}
@@ -368,6 +373,8 @@ snap_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
register int ret;
ND_TCHECK2(*p, 5);
+ if (caplen < 5 || length < 5)
+ goto trunc;
orgcode = EXTRACT_24BITS(p);
et = EXTRACT_16BITS(p + 3);