]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
check input length against minimum size
authorAlan T. DeKok <aland@freeradius.org>
Wed, 30 Oct 2019 21:18:06 +0000 (17:18 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 30 Oct 2019 21:18:06 +0000 (17:18 -0400)
src/lib/util/value.c

index 3762d4c4ac38719063487684196ee88052b3237b..60dbe03946a45e876e231b86ff60db9ec3ed328b 100644 (file)
@@ -1429,7 +1429,7 @@ ssize_t fr_value_box_from_network(TALLOC_CTX *ctx,
                 */
        case FR_TYPE_DATE:
        {
-               int i, length = 4;
+               size_t i, length = 4;
                int precision = FR_TIME_RES_SEC;
                uint64_t date;
                struct timespec ts;
@@ -1439,6 +1439,12 @@ ssize_t fr_value_box_from_network(TALLOC_CTX *ctx,
                        precision = enumv->flags.type_size;
                }
 
+               /*
+                *      Input data doesn't match what we were told we
+                *      need.
+                */
+               if (len != length) return -1;
+
                /*
                 *      Just loop over the input data until we reach
                 *      the end.  Shifting it every time.
@@ -1483,7 +1489,7 @@ ssize_t fr_value_box_from_network(TALLOC_CTX *ctx,
 
        case FR_TYPE_TIME_DELTA:
        {
-               int i, length = 4;
+               size_t i, length = 4;
                int precision = FR_TIME_RES_SEC;
                uint64_t date;
 
@@ -1492,6 +1498,12 @@ ssize_t fr_value_box_from_network(TALLOC_CTX *ctx,
                        precision = enumv->flags.type_size;
                }
 
+               /*
+                *      Input data doesn't match what we were told we
+                *      need.
+                */
+               if (len != length) return -1;
+
                /*
                 *      Just loop over the input data until we reach
                 *      the end.  Shifting it every time.