]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
NULL types on input yield NULL types on output.
authorAlan T. DeKok <aland@freeradius.org>
Fri, 27 May 2022 21:41:22 +0000 (17:41 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 3 Jun 2022 11:15:46 +0000 (07:15 -0400)
src/lib/util/calc.c

index cd39220e30f3a587ae707c7028d0572277ba28fd..887578493382e36f4b4f3c4d6d68740c75d9503a 100644 (file)
@@ -1604,6 +1604,18 @@ int fr_value_calc_binary_op(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_type_t hint
 
        if ((hint != FR_TYPE_NULL) && !fr_type_is_leaf(hint)) return invalid_type(hint);
 
+       /*
+        *      Any operation on NULL types is itself a NULL type.
+        */
+       if ((a->type == FR_TYPE_NULL) || (b->type == FR_TYPE_NULL)) {
+               fr_value_box_init_null(dst);
+               return 0;
+       }
+
+       /*
+        *      Casting to structural types should be a parse error,
+        *      and not a run-time calculation error.
+        */
        if (!fr_type_is_leaf(a->type)) return invalid_type(a->type);
        if (!fr_type_is_leaf(b->type)) return invalid_type(b->type);