X-Git-Url: https://git.saurik.com/apple/network_cmds.git/blobdiff_plain/07f470571f6fc2709bdcf62fad0e6c4c1bf4e1b9..8d01c3442b975fe0fe2e3fb87b8c8b61d637f8eb:/alias/alias.c diff --git a/alias/alias.c b/alias/alias.c index 1d3cd05..668dbe1 100644 --- a/alias/alias.c +++ b/alias/alias.c @@ -3,22 +3,19 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -194,18 +191,32 @@ static void DoMSSClamp(struct tcphdr *tc) u_char *option = (u_char *) tc + sizeof(*tc); u_char *optionEnd = option + ((tc->th_off << 2) - sizeof(*tc)); +#define TEST_5618045 0 +#if TEST_5618045 + if ((ntohs(tc->th_dport) == 8080 || ntohs(tc->th_sport) == 8080) && tc->th_off > 5) { + option[0] = 0xF4; + option[1] = 0; + } +#endif + 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) { @@ -215,9 +226,12 @@ static void DoMSSClamp(struct tcphdr *tc) if (packetAliasMSS < mssVal) { int accumulate = mssVal; + int accnetorder = 0 ; + accumulate -= packetAliasMSS; *mssPtr = htons(packetAliasMSS); - ADJUST_CHECKSUM(accumulate, tc->th_sum); + accnetorder = htons(accumulate); + ADJUST_CHECKSUM(accnetorder, tc->th_sum); } option = optionEnd; @@ -1473,7 +1487,7 @@ PacketAliasOut(char *ptr, /* valid IP packet */ addr_save = GetDefaultAliasAddress(); if (packetAliasMode & PKT_ALIAS_UNREGISTERED_ONLY) { - u_long addr; + in_addr_t addr; int iclass; iclass = 0;