]> The Tcpdump Group git mirrors - tcpdump/commitdiff
ARP: fix overwrites of static buffer in q922_string().
authorGuy Harris <[email protected]>
Tue, 25 May 2021 22:22:49 +0000 (15:22 -0700)
committerGuy Harris <[email protected]>
Tue, 25 May 2021 22:22:49 +0000 (15:22 -0700)
Don't call GET_LINKADDR_STRING() twice in a given ND_PRINT() call.

Should address another problem in GitHub issue #919.

print-arp.c

index 4855332bbae2b88a70b6ef49e4d7a70bb7351eaf..7d3efe74fa02e74b2e9f092338d3111a98cda594 100644 (file)
@@ -424,8 +424,16 @@ arp_print(netdissect_options *ndo,
                break;
 
        case ARPOP_REVREQUEST:
-               ND_PRINT("who-is %s tell %s",
-                         GET_LINKADDR_STRING(THA(ap), linkaddr, HRD_LEN(ap)),
+               /*
+                * XXX - GET_LINKADDR_STRING() may return a pointer to
+                * a static buffer, so we only have one call to it per
+                * ND_PRINT() call.
+                *
+                * This should be done in a cleaner fashion.
+                */
+               ND_PRINT("who-is %s",
+                         GET_LINKADDR_STRING(THA(ap), linkaddr, HRD_LEN(ap)));
+               ND_PRINT(" tell %s",
                          GET_LINKADDR_STRING(SHA(ap), linkaddr, HRD_LEN(ap)));
                break;
 
@@ -436,8 +444,16 @@ arp_print(netdissect_options *ndo,
                break;
 
        case ARPOP_INVREQUEST:
-               ND_PRINT("who-is %s tell %s",
-                         GET_LINKADDR_STRING(THA(ap), linkaddr, HRD_LEN(ap)),
+               /*
+                * XXX - GET_LINKADDR_STRING() may return a pointer to
+                * a static buffer, so we only have one call to it per
+                * ND_PRINT() call.
+                *
+                * This should be done in a cleaner fashion.
+                */
+               ND_PRINT("who-is %s",
+                         GET_LINKADDR_STRING(THA(ap), linkaddr, HRD_LEN(ap)));
+               ND_PRINT(" tell %s",
                          GET_LINKADDR_STRING(SHA(ap), linkaddr, HRD_LEN(ap)));
                break;