From: Apple Date: Sat, 4 Oct 2008 02:05:21 +0000 (+0000) Subject: network_cmds-307.0.1.tar.gz X-Git-Tag: mac-os-x-1056^0 X-Git-Url: https://git.saurik.com/apple/network_cmds.git/commitdiff_plain/c03750dc6ce5230ceb263974e99c2ef3ff4d3c61 network_cmds-307.0.1.tar.gz --- diff --git a/alias/alias.c b/alias/alias.c index 53273ab..a9e39c6 100644 --- a/alias/alias.c +++ b/alias/alias.c @@ -193,16 +193,22 @@ static void DoMSSClamp(struct tcphdr *tc) while (optionEnd > option) { - switch (option[0]) - { - case TCPOPT_EOL: - option = optionEnd; + /* Bounds checking to avoid infinite loops */ + if (option[0] == TCPOPT_EOL) + break; + + if (option[0] == TCPOPT_NOP) { + ++option; + continue; + } else { + if (optionEnd - option < 2) break; - - case TCPOPT_NOP: - ++option; + if (option[1] < 2 || option + option[1] >= optionEnd) break; + } + switch (option[0]) + { case TCPOPT_MAXSEG: if (option[1] == 4) { @@ -212,10 +218,11 @@ static void DoMSSClamp(struct tcphdr *tc) if (packetAliasMSS < mssVal) { int accumulate = mssVal; - int accnetorder = 0 ; + int accnetorder = 0 ; + accumulate -= packetAliasMSS; *mssPtr = htons(packetAliasMSS); - accnetorder = htons(accumulate); + accnetorder = htons(accumulate); ADJUST_CHECKSUM(accnetorder, tc->th_sum); }