]> The Tcpdump Group git mirrors - tcpdump/commitdiff
UDP: Fix fetching the header payload length
authorFrancois-Xavier Le Bail <[email protected]>
Tue, 30 Apr 2019 21:23:10 +0000 (23:23 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Tue, 30 Apr 2019 21:54:33 +0000 (23:54 +0200)
... and a Clang warning.

The warning was:
./print-udp.c:574:104: warning: address of array
      'ip6->ip6_ctlun.ip6_un1.ip6_un1_plen' will always evaluate to 'true'
      [-Wpointer-bool-conversion]
  ...& 0xf0) >> 4) == 6 && ip6->ip6_ctlun.ip6_un1.ip6_un1_plen) {
                        ~~ ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~

print-udp.c

index 231d8b4fdc92e7ac694447b14ab43a1a6a0d74b7..ed517580e356734ddeafa70989f26dd160e9f21f 100644 (file)
@@ -571,7 +571,7 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
                                        ND_PRINT("[udp sum ok] ");
                        }
                }
-               else if (IP_V(ip) == 6 && ip6->ip6_plen) {
+               else if (IP_V(ip) == 6 && GET_BE_U_2(ip6->ip6_plen)) {
                        /* for IPv6, UDP checksum is mandatory */
                        if (ND_TTEST_LEN(cp, length)) {
                                sum = udp6_cksum(ndo, ip6, up, length + sizeof(struct udphdr));