]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Walk over padding bytes when decoding DHCPv4
authorNick Porter <nick@portercomputing.co.uk>
Tue, 3 Sep 2024 17:09:47 +0000 (18:09 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Tue, 3 Sep 2024 17:09:47 +0000 (18:09 +0100)
Packets are allowed to contain as many bytes of Pad Option as they want.
They have been seen in the wild with 50 bytes of 0, then with more valid
options after...

src/protocols/dhcpv4/decode.c

index 7fdc866393aad090c39079752be0b1dfdc2e2e95..e334d4891a0f47cdcffb5cb8e8589500a8786176 100644 (file)
@@ -552,7 +552,15 @@ ssize_t fr_dhcpv4_decode_option(TALLOC_CTX *ctx, fr_pair_list_t *out,
        /*
         *      Padding / End of options
         */
-       if (p[0] == 0) return data_len;         /* 0x00 - Padding option */
+       if (p[0] == 0) {                        /* 0x00 - Padding option          */
+               data_len = 1;                   /* Walk over any consecutive 0x00 */
+               p++;                            /* for efficiency                 */
+               while ((p < end) && (p[0] == 0)) {
+                       p++;
+                       data_len ++;
+               }
+               return data_len;
+       }
        if (p[0] == 255) return data_len;       /* 0xff - End of options signifier */
 
        /*