summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeonah Moon <seonah1.moon@samsung.com>2023-02-20 16:04:12 +0900
committerSeonah Moon <seonah1.moon@samsung.com>2023-02-20 16:04:13 +0900
commitc5e6e120e0a1c4b54fbc8ba16bbd7a44ae1f0f99 (patch)
treeae1323c09d51b1e30c6c30e11b5eac3359d2e70c
parentcd2ca79be2dc09082707a37cdeaa0f639cfce60d (diff)
downloadtcpdump-accepted/tizen_6.0_unified.tar.gz
tcpdump-accepted/tizen_6.0_unified.tar.bz2
tcpdump-accepted/tizen_6.0_unified.zip
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 e4add0b) CVE-2020-8037 Change-Id: I46cc3abe30a02881458bdde49caea6e4f5aff1c4
-rw-r--r--print-ppp.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/print-ppp.c b/print-ppp.c
index 8917617..bdb1829 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 (length <= 0)
- return;
+ 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;