]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Fix to DHCP encoding error when sub-option doesn't fit 2209/head
authornchaigne <nchaigne@capgemini.fr>
Fri, 6 Apr 2018 18:14:25 +0000 (20:14 +0200)
committernchaigne <nchaigne@capgemini.fr>
Fri, 6 Apr 2018 18:14:25 +0000 (20:14 +0200)
Ask FreeRADIUS to encode several sub-options too long to fit in one option.
Then the first option is not properly encoded. There are two octets leftover (the beginning of the second sub-option).

Here is a fix.

src/protocols/dhcpv4/encode.c

index 498fcd15c69e89af452bea0b9bd6c985cc15c3ee..0c6723283cbe22c04494ff6b6bd420ecb97d6b89 100644 (file)
@@ -172,6 +172,10 @@ static ssize_t encode_rfc_hdr(uint8_t *out, ssize_t outlen,
                if (len < 0) return len;
                if (len == 0) {
                        FR_PROTO_TRACE("No more space in option");
+                       if (out[1] == 0) {
+                               /* Couldn't encode anything: don't leave behind these two octets. */
+                               p -= 2;
+                       }
                        break; /* Packed as much as we can */
                }