]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add tests. and decode multiple VSAs in option 125
authorAlan T. DeKok <aland@freeradius.org>
Mon, 5 Oct 2020 17:06:06 +0000 (13:06 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 5 Oct 2020 17:06:06 +0000 (13:06 -0400)
src/protocols/dhcpv4/decode.c
src/tests/unit/protocols/dhcpv4/vendor.txt [new file with mode: 0644]

index 9960582fc8ec018ffa1ae69190199647ba0119ef..dd496777cceb2c2291c19cca0d56bf6d7fc66829 100644 (file)
@@ -359,6 +359,7 @@ static ssize_t decode_vsa(TALLOC_CTX *ctx, fr_cursor_t *cursor, fr_dict_attr_t c
        ssize_t                 len;
        uint32_t                pen;
        fr_dict_attr_t const    *da;
+       uint8_t const           *end;
 
        FR_PROTO_HEX_DUMP(data, data_len, "decode_vsa");
 
@@ -377,6 +378,9 @@ static ssize_t decode_vsa(TALLOC_CTX *ctx, fr_cursor_t *cursor, fr_dict_attr_t c
                return decode_value(ctx, cursor, parent, data, data_len);
        }
 
+       end = data + data_len;
+
+next:
        memcpy(&pen, data, sizeof(pen));
        pen = htonl(pen);
 
@@ -408,6 +412,9 @@ static ssize_t decode_vsa(TALLOC_CTX *ctx, fr_cursor_t *cursor, fr_dict_attr_t c
        len = decode_tlv(ctx, cursor, da, data + 5, data[4]);
        if (len <= 0) return len;
 
+       data += 5 + len;
+       if (data < end) goto next;
+
        /*
         *      Tell the caller we read all of it, even if we didn't.
         */
diff --git a/src/tests/unit/protocols/dhcpv4/vendor.txt b/src/tests/unit/protocols/dhcpv4/vendor.txt
new file mode 100644 (file)
index 0000000..b0c31ae
--- /dev/null
@@ -0,0 +1,17 @@
+#
+#  Test vectors for Vendor-Specific DHCP attributes
+#
+proto dhcpv4
+proto-dictionary dhcpv4
+
+encode-pair Cisco-Indirect-Image-Filename = "aa.txt"
+match 7d 0d 00 00 00 09 08 05 06 61 61 2e 74 78 74
+
+decode-pair -
+match Cisco-Indirect-Image-Filename = "aa.txt"
+
+decode-pair 7d 1a 00 00 00 09 08 05 06 61 61 2e 74 78 74 00 00 00 09 08 05 06 62 62 2e 74 78 74
+match Cisco-Indirect-Image-Filename = "aa.txt", Cisco-Indirect-Image-Filename = "bb.txt"
+
+count
+match 8