]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ip.c
Use more the EXTRACT_U_1() macro (55/n)
[tcpdump] / print-ip.c
index 036c57cda73f87a54ff83446d962ab8fb5f58487..b9d39cf511dde65db4230b6596419e9091e9fe46 100644 (file)
@@ -68,7 +68,7 @@ ip_printroute(netdissect_options *ndo,
        if ((length + 1) & 3)
                ND_PRINT((ndo, " [bad length %u]", length));
        ND_TCHECK_1(cp + 2);
-       ptr = cp[2] - 1;
+       ptr = EXTRACT_U_1(cp + 2) - 1;
        if (ptr < 3 || ((ptr + 1) & 3) || ptr > length + 1)
                ND_PRINT((ndo, " [bad ptr %u]", EXTRACT_U_1(cp + 2)));
 
@@ -182,11 +182,12 @@ ip_printts(netdissect_options *ndo,
                return (0);
        }
        ND_PRINT((ndo, " TS{"));
-       hoplen = ((cp[3]&0xF) != IPOPT_TS_TSONLY) ? 8 : 4;
+       ND_TCHECK_1(cp + 3);
+       hoplen = ((EXTRACT_U_1(cp + 3) & 0xF) != IPOPT_TS_TSONLY) ? 8 : 4;
        if ((length - 4) & (hoplen-1))
                ND_PRINT((ndo, "[bad length %u]", length));
        ND_TCHECK_1(cp + 2);
-       ptr = cp[2] - 1;
+       ptr = EXTRACT_U_1(cp + 2) - 1;
        len = 0;
        if (ptr < 4 || ((ptr - 4) & (hoplen-1)) || ptr > length + 1)
                ND_PRINT((ndo, "[bad ptr %u]", EXTRACT_U_1(cp + 2)));