]> The Tcpdump Group git mirrors - tcpdump/commitdiff
BGP: Fix a ND_TCHECK_LEN() use
authorFrancois-Xavier Le Bail <[email protected]>
Sun, 14 Jun 2020 11:54:24 +0000 (13:54 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Sun, 14 Jun 2020 16:14:06 +0000 (18:14 +0200)
The error was:
reading from file bgp-rt-prefix.pcap, link-type EN10MB (Ethernet), snapshot
length 262144
==22310==WARNING: MemorySanitizer: use-of-uninitialized-value
[...]

SUMMARY: MemorySanitizer: use-of-uninitialized-value print-bgp.c:1040:5
in decode_rt_routing_info

Moreover:
Simplify a pointer expression.

print-bgp.c

index 5e9582ce5637e4a752c17226c0247fb2c0865d11..e5512ed89c1d1ac625072f39014cb701807b4364 100644 (file)
@@ -1037,8 +1037,8 @@ decode_rt_routing_info(netdissect_options *ndo,
      */
     memset(&route_target, 0, sizeof(route_target));
     num_octets = (plen + 7) / 8;
-    ND_TCHECK_LEN(pptr[5], num_octets);
-    memcpy(&route_target, &pptr[5], num_octets);
+    ND_TCHECK_LEN(pptr + 5, num_octets);
+    memcpy(&route_target, pptr + 5, num_octets);
     /* If mask-len is not on octet boundary, ensure all extra bits are 0 */
     if (plen % 8) {
         ((u_char *)&route_target)[num_octets - 1] &=