diff options
author | Guy Harris <guy@alum.mit.edu> | 2020-04-18 14:04:59 -0700 |
---|---|---|
committer | Seonah Moon <seonah1.moon@samsung.com> | 2020-12-17 12:39:48 +0900 |
commit | 96a25eca5a5fa8ca57af059f3d14e02378cf1fba (patch) | |
tree | 7071be9dcb2db1134bbe618b665dc2230c7b7cc4 | |
parent | b0706e54b48af6c11783f55455842a292c4d9b17 (diff) | |
download | tcpdump-96a25eca5a5fa8ca57af059f3d14e02378cf1fba.tar.gz tcpdump-96a25eca5a5fa8ca57af059f3d14e02378cf1fba.tar.bz2 tcpdump-96a25eca5a5fa8ca57af059f3d14e02378cf1fba.zip |
PPP: When un-escaping, don't allocate a too-large buffer.tizen_8.0_m2_releasetizen_7.0_m2_releasetizen_6.5.m2_releasesubmit/tizen_6.5/20211028.163901submit/tizen/20210106.042955submit/tizen/20201218.054408accepted/tizen/unified/20210107.123455accepted/tizen/8.0/unified/20231005.095602accepted/tizen/7.0/unified/hotfix/20221116.111453accepted/tizen/7.0/unified/20221110.061409accepted/tizen/6.5/unified/20211029.015054tizen_8.0tizen_7.0_hotfixtizen_7.0tizen_6.5accepted/tizen_8.0_unifiedaccepted/tizen_7.0_unified_hotfixaccepted/tizen_7.0_unifiedaccepted/tizen_6.5_unified
The buffer should be big enough to hold the captured data, but it
doesn't need to be big enough to hold the entire on-the-network packet,
if we haven't captured all of it.
(backported from commit e4add0b010ed6f2180dcb05a13026242ed935334)
CVE-2020-8037
Change-Id: Ic28093fcb75e2c597aa8486bf81427fa244694a2
-rw-r--r-- | print-ppp.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/print-ppp.c b/print-ppp.c index 8917617..33fb034 100644 --- a/print-ppp.c +++ b/print-ppp.c @@ -1367,19 +1367,29 @@ trunc: return 0; } +/* + * Un-escape RFC 1662 PPP in HDLC-like framing, with octet escapes. + * The length argument is the on-the-wire length, not the captured + * length; we can only un-escape the captured part. + */ static void ppp_hdlc(netdissect_options *ndo, const u_char *p, int length) { + u_int caplen = ndo->ndo_snapend - p; u_char *b, *t, c; const u_char *s; - int i, proto; + u_int i; + int proto; const void *se; + if (caplen == 0) + return; + if (length <= 0) return; - b = (u_char *)malloc(length); + b = (u_char *)malloc(caplen); if (b == NULL) return; @@ -1388,10 +1398,10 @@ ppp_hdlc(netdissect_options *ndo, * Do this so that we dont overwrite the original packet * contents. */ - for (s = p, t = b, i = length; i > 0 && ND_TTEST(*s); i--) { + for (s = p, t = b, i = caplen; i != 0; i--) { c = *s++; if (c == 0x7d) { - if (i <= 1 || !ND_TTEST(*s)) + if (i <= 1) break; i--; c = *s++ ^ 0x20; |