summaryrefslogtreecommitdiff
path: root/print-atalk.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2015-07-03 11:43:30 -0700
committerFrancois-Xavier Le Bail <fx.lebail@yahoo.com>2017-01-18 09:16:35 +0100
commit5356a9ea6903b835185eda83e8a17d6e4e990fb5 (patch)
treea54d7b4275780ee33a7e754ab8462de43dad5a05 /print-atalk.c
parent4ef024c8e94459e3ab9afae90e1948406e1d04db (diff)
downloadtcpdump-5356a9ea6903b835185eda83e8a17d6e4e990fb5.tar.gz
CVE-2016-7973/Add some bounds checks.
Fixes a heap overflow found with American Fuzzy Lop by Hanno Böck.
Diffstat (limited to 'print-atalk.c')
-rw-r--r--print-atalk.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/print-atalk.c b/print-atalk.c
index 2a674990..59de3a67 100644
--- a/print-atalk.c
+++ b/print-atalk.c
@@ -77,7 +77,14 @@ u_int
ltalk_if_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, const u_char *p)
{
- return (llap_print(ndo, p, h->caplen));
+ u_int hdrlen;
+
+ hdrlen = llap_print(ndo, p, h->caplen);
+ if (hdrlen == 0) {
+ /* Cut short by the snapshot length. */
+ return (h->caplen);
+ }
+ return (hdrlen);
}
/*
@@ -93,6 +100,10 @@ llap_print(netdissect_options *ndo,
u_short snet;
u_int hdrlen;
+ if (!ND_TTEST2(*bp, sizeof(*lp))) {
+ ND_PRINT((ndo, " [|llap]"));
+ return (0); /* cut short by the snapshot length */
+ }
if (length < sizeof(*lp)) {
ND_PRINT((ndo, " [|llap %u]", length));
return (length);
@@ -104,6 +115,10 @@ llap_print(netdissect_options *ndo,
switch (lp->type) {
case lapShortDDP:
+ if (!ND_TTEST2(*bp, ddpSSize)) {
+ ND_PRINT((ndo, " [|sddp]"));
+ return (0); /* cut short by the snapshot length */
+ }
if (length < ddpSSize) {
ND_PRINT((ndo, " [|sddp %u]", length));
return (length);
@@ -120,6 +135,10 @@ llap_print(netdissect_options *ndo,
break;
case lapDDP:
+ if (!ND_TTEST2(*bp, ddpSize)) {
+ ND_PRINT((ndo, " [|ddp]"));
+ return (0); /* cut short by the snapshot length */
+ }
if (length < ddpSize) {
ND_PRINT((ndo, " [|ddp %u]", length));
return (length);
@@ -166,6 +185,10 @@ atalk_print(netdissect_options *ndo,
if(!ndo->ndo_eflag)
ND_PRINT((ndo, "AT "));
+ if (!ND_TTEST2(*bp, ddpSize)) {
+ ND_PRINT((ndo, " [|ddp]"));
+ return;
+ }
if (length < ddpSize) {
ND_PRINT((ndo, " [|ddp %u]", length));
return;