From: Francois-Xavier Le Bail Date: Thu, 20 Mar 2025 13:10:13 +0000 (+0100) Subject: DHCP: Fix printing boolean options X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/3230fc0be664705472916ace8fc83359ba9dd9b2 DHCP: Fix printing boolean options For 'B', the options 19, 20, 27, 29, 30, 31, 34, 36, 39 and 116 that use it are only 1 octet "0/1" boolean. No need for a while loop. Print an error message if the length is not 1. (backported from commit 711571721fd3f13f1082e4e803c4066e1a51c540) --- diff --git a/print-bootp.c b/print-bootp.c index 747a9836..a541d74e 100644 --- a/print-bootp.c +++ b/print-bootp.c @@ -730,27 +730,32 @@ rfc1048_print(netdissect_options *ndo, case 'B': /* boolean */ - while (len > 0) { - uint8_t bool_value; - if (!first) - ND_PRINT(","); - bool_value = GET_U_1(bp); - switch (bool_value) { - case 0: - ND_PRINT("N"); - break; - case 1: - ND_PRINT("Y"); - break; - default: - ND_PRINT("%u?", bool_value); - break; - } - ++bp; - --len; - first = 0; + { + /* this option should be 1 byte long */ + if (len != 1) { + ND_PRINT("[ERROR: length != 1 byte]"); + bp += len; + len = 0; + break; + } + + uint8_t bool_value; + bool_value = GET_U_1(bp); + switch (bool_value) { + case 0: + ND_PRINT("N"); + break; + case 1: + ND_PRINT("Y"); + break; + default: + ND_PRINT("%u?", bool_value); + break; } + ++bp; + --len; break; + } case 'b': case 'x':