]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
dhcpv6: Don't return 0 on error
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 2 Oct 2020 03:28:36 +0000 (22:28 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 2 Oct 2020 03:28:36 +0000 (22:28 -0500)
src/protocols/dhcpv6/decode.c

index 3237ef6276dd6e33a326ef56c88f64ec77caa540..e335ba60e2957f134d10976b836d3f4910978926 100644 (file)
@@ -519,9 +519,11 @@ static ssize_t decode_option(TALLOC_CTX *ctx, fr_cursor_t *cursor, fr_dict_t con
 
        option = (data[0] << 8) | data[1];
        len = (data[2] << 8) | data[3];
-       if ((len + 4) > data_len) {
-               fr_strerror_printf("%s: Option overflows input", __FUNCTION__);
-               return 0;
+       if (len > (data_len - 4)) {
+               fr_strerror_printf("%s: Option overflows input.  "
+                                  "Optional length must be less than %zu bytes, got %zu bytes",
+                                  __FUNCTION__, data_len - 4, len);
+               return PAIR_DECODE_FATAL_ERROR;
        }
 
        da = fr_dict_attr_child_by_num(parent, option);