]> The Tcpdump Group git mirrors - tcpdump/commitdiff
DVMRP: Fix an undefined behavior at runtime
authorFrancois-Xavier Le Bail <[email protected]>
Sun, 8 Jul 2018 13:03:45 +0000 (15:03 +0200)
committerGuy Harris <[email protected]>
Mon, 15 Oct 2018 17:13:56 +0000 (10:13 -0700)
Found with -fsanitize=undefined clang compiler option.

The error was:
print-dvmrp.c:238:27: runtime error: left shift of 240 by 24 places cannot
be represented in type 'int'

(cherry picked from commit bc3e9de3e4cfdf8edc7f486d6918bec8e14903bb)

print-dvmrp.c

index e6e87667123c07b4f1b93a9aae921c8037263fe2..36a8d5ba8ec6417cd745b82c49cb6db362e5991a 100644 (file)
@@ -231,7 +231,7 @@ print_probe(netdissect_options *ndo,
                ND_PRINT((ndo, " [|}"));
                return (0);
        }
-       genid = (bp[0] << 24) | (bp[1] << 16) | (bp[2] << 8) | bp[3];
+       genid = EXTRACT_32BITS(bp);
        bp += 4;
        len -= 4;
        ND_PRINT((ndo, ndo->ndo_vflag > 1 ? "\n\t" : " "));