]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-tcp.c
IPX: Add a length check
[tcpdump] / print-tcp.c
index 4b605733ff483dc1577e63a8081b46bd80fba672..66834e84fe7d2bdc2d620e7b8b63bba4bf96f978 100644 (file)
@@ -95,7 +95,7 @@ struct tcp_seq_hash6 {
 
 #define TSEQ_HASHSIZE 919
 
-/* These tcp optinos do not have the size octet */
+/* These tcp options do not have the size octet */
 #define ZEROLENOPT(o) ((o) == TCPOPT_EOL || (o) == TCPOPT_NOP)
 
 static struct tcp_seq_hash tcp_seq_hash4[TSEQ_HASHSIZE];
@@ -136,7 +136,7 @@ static const struct tok tcp_option_values[] = {
         { 0, NULL }
 };
 
-static int
+static uint16_t
 tcp_cksum(netdissect_options *ndo,
           const struct ip *ip,
           const struct tcphdr *tp,
@@ -146,7 +146,7 @@ tcp_cksum(netdissect_options *ndo,
                                 IPPROTO_TCP);
 }
 
-static int
+static uint16_t
 tcp6_cksum(netdissect_options *ndo,
            const struct ip6_hdr *ip6,
            const struct tcphdr *tp,
@@ -543,7 +543,7 @@ tcp_print(netdissect_options *ndo,
                                         break;
 
                                 case SIGNATURE_INVALID:
-                                        ND_PRINT("invalid");
+                                        nd_print_invalid(ndo);
                                         break;
 
                                 case CANT_CHECK_SIGNATURE:
@@ -572,7 +572,7 @@ tcp_print(netdissect_options *ndo,
                                  * at this point.)
                                  */
                                 if (datalen < 2) {
-                                        ND_PRINT(" invalid");
+                                        nd_print_invalid(ndo);
                                 } else {
                                         LENCHECK(1);
                                         ND_PRINT(" keyid %u", EXTRACT_U_1(cp));
@@ -709,7 +709,8 @@ tcp_print(netdissect_options *ndo,
                 smtp_print(ndo, bp, length);
         } else if (IS_SRC_OR_DST_PORT(WHOIS_PORT)) {
                 ND_PRINT(": ");
-                txtproto_print(ndo, bp, length, "whois", NULL, 0); /* RFC 3912 */
+                ndo->ndo_protocol = "whois";   /* needed by txtproto_print() */
+                txtproto_print(ndo, bp, length, NULL, 0); /* RFC 3912 */
         } else if (IS_SRC_OR_DST_PORT(BGP_PORT))
                 bgp_print(ndo, bp, length);
         else if (IS_SRC_OR_DST_PORT(PPTP_PORT))
@@ -820,7 +821,7 @@ static void
 print_tcp_rst_data(netdissect_options *ndo,
                    const u_char *sp, u_int length)
 {
-        int c;
+        u_char c;
 
         ND_PRINT(ND_TTEST_LEN(sp, length) ? " [RST" : " [!RST");
         if (length > MAX_RST_DATA_LEN) {
@@ -828,10 +829,11 @@ print_tcp_rst_data(netdissect_options *ndo,
                 ND_PRINT("+");                 /* indicate we truncate */
         }
         ND_PRINT(" ");
-        while (length-- && sp < ndo->ndo_snapend) {
+        while (length && sp < ndo->ndo_snapend) {
                 c = EXTRACT_U_1(sp);
                 sp++;
                 fn_print_char(ndo, c);
+                length--;
         }
         ND_PRINT("]");
 }
@@ -851,7 +853,7 @@ print_tcp_fastopen_option(netdissect_options *ndo, const u_char *cp,
         } else {
                 /* Fast Open Cookie */
                 if (datalen % 2 != 0 || datalen < 4 || datalen > 16) {
-                        ND_PRINT(" invalid");
+                        nd_print_invalid(ndo);
                 } else {
                         ND_PRINT(" cookie ");
                         for (i = 0; i < datalen; ++i)