From: Alan T. DeKok Date: Fri, 27 May 2022 21:41:22 +0000 (-0400) Subject: NULL types on input yield NULL types on output. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9681786ca6984872d7329bf3bb6933ba194847d9;p=thirdparty%2Ffreeradius-server.git NULL types on input yield NULL types on output. --- diff --git a/src/lib/util/calc.c b/src/lib/util/calc.c index cd39220e30f..88757849338 100644 --- a/src/lib/util/calc.c +++ b/src/lib/util/calc.c @@ -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);