]> 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)
committerfxlb <[email protected]>
Wed, 8 Jan 2025 07:21:08 +0000 (07:21 +0000)
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

print-bootp.c

index b4cefd3d9ef59fcb839d68fad11c8d620aa97b23..d98e585cacb89529e2c0b81482c7e48a7bc765df 100644 (file)
@@ -1006,22 +1006,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]");