]> The Tcpdump Group git mirrors - tcpdump/commitdiff
BOOTP: Use an uint16_t variable to get the result of a GET_BE_U_2()
authorFrancois-Xavier Le Bail <[email protected]>
Tue, 7 Jan 2025 10:54:11 +0000 (11:54 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Wed, 8 Jan 2025 09:48:24 +0000 (10:48 +0100)
This will fix this Visual Studio warning:
print-bootp.c(1009,18): warning C4242: =: conversion from uint16_t to
uint8_t, possible loss of data

(cherry picked from commit 805fd42b376aea1da2ec4314c13337d45680bbfb)

print-bootp.c

index b20dabc64052f64ccb9da0274a4410987e12f627..646e3f333731beb2d7ee8458c11003c7ea392b92 100644 (file)
@@ -1012,22 +1012,24 @@ rfc1048_print(netdissect_options *ndo,
                                 * URI: URI of the SZTP bootstrap server.
                                 */
                                while (len >= 2) {
-                                       suboptlen = GET_BE_U_2(bp);
+                                       uint16_t suboptlen2;
+
+                                       suboptlen2 = GET_BE_U_2(bp);
                                        bp += 2;
                                        len -= 2;
                                        ND_PRINT("\n\t      ");
-                                       ND_PRINT("length %u: ", suboptlen);
-                                       if (len < suboptlen) {
+                                       ND_PRINT("length %u: ", suboptlen2);
+                                       if (len < suboptlen2) {
                                                ND_PRINT("length goes past end of option");
                                                bp += len;
                                                len = 0;
                                                break;
                                        }
                                        ND_PRINT("\"");
-                                       nd_printjn(ndo, bp, suboptlen);
+                                       nd_printjn(ndo, bp, suboptlen2);
                                        ND_PRINT("\"");
-                                       len -= suboptlen;
-                                       bp += suboptlen;
+                                       len -= suboptlen2;
+                                       bp += suboptlen2;
                                }
                                if (len != 0) {
                                        ND_PRINT("[ERROR: length < 2 bytes]");