]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
-NULL and ~NULL is an error. !NULL is true.
authorAlan T. DeKok <aland@freeradius.org>
Tue, 7 Jun 2022 20:52:58 +0000 (16:52 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 17 Jun 2022 12:30:25 +0000 (08:30 -0400)
src/lib/unlang/xlat_expr.c

index 07c95acc5fcab00f8595b5a5dfed6d0e7f6f07b3..1764f07f93aff9cdcf2adc6f5507473b07933f5b 100644 (file)
@@ -1078,6 +1078,13 @@ static xlat_action_t xlat_func_unary_op(TALLOC_CTX *ctx, fr_dcursor_t *out,
        group = fr_dlist_head(in);
        vb = fr_dlist_head(&group->vb_group);
 
+       /*
+        *      -NULL is an error
+        *      ~NULL is an error
+        *      !NULL is handled by xlat_func_unary_not
+        */
+       if (!vb) return XLAT_ACTION_FAIL;
+
        if (!fr_type_is_leaf(vb->type) || fr_type_is_variable_size(vb->type)) {
                REDEBUG("Cannot perform operation on data type %s", fr_type_to_str(vb->type));
                return XLAT_ACTION_FAIL;
@@ -1112,7 +1119,15 @@ static xlat_action_t xlat_func_unary_not(TALLOC_CTX *ctx, fr_dcursor_t *out,
         *      Don't call calc_unary_op(), because we want the enum names.
         */
        MEM(dst = fr_value_box_alloc(ctx, FR_TYPE_BOOL, attr_expr_bool_enum, false));
-       dst->vb_bool = !fr_value_box_is_truthy(vb);
+
+       /*
+        *      !NULL = true
+        */
+       if (!vb) {
+               dst->vb_bool = true;
+       } else {
+               dst->vb_bool = !fr_value_box_is_truthy(vb);
+       }
 
        fr_dcursor_append(out, dst);
        return XLAT_ACTION_DONE;