]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
don't mash NUM_UNSPEC to NUM_ALL for edit lists
authorAlan T. DeKok <aland@freeradius.org>
Fri, 12 Aug 2022 15:43:00 +0000 (11:43 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 12 Aug 2022 15:43:00 +0000 (11:43 -0400)
src/lib/unlang/compile.c

index d9b0662322d79d85a86fce39fa85fcc6ec639fb3..8f09e57d98116c95d8fee67eae9671405841ef0b 100644 (file)
@@ -816,7 +816,7 @@ static int unlang_fixup_map(map_t *map, UNUSED void *ctx)
  *     - 0 if valid.
  *     - -1 not valid.
  */
-int unlang_fixup_update(map_t *map, UNUSED void *ctx)
+int unlang_fixup_update(map_t *map, void *ctx)
 {
        CONF_PAIR *cp = cf_item_to_pair(map->ci);
 
@@ -836,29 +836,31 @@ int unlang_fixup_update(map_t *map, UNUSED void *ctx)
        }
 
        /*
-        *      Fixup LHS attribute references to change NUM_UNSPEC to NUM_ALL.
+        *      Fixup LHS attribute references to change NUM_UNSPEC to NUM_ALL, but only for "update" sections.
         */
-       switch (map->lhs->type) {
-       case TMPL_TYPE_ATTR:
-       case TMPL_TYPE_LIST:
-               tmpl_attr_rewrite_leaf_num(map->lhs, NUM_UNSPEC, NUM_ALL);
-               break;
+       if (!ctx) {
+               switch (map->lhs->type) {
+               case TMPL_TYPE_ATTR:
+               case TMPL_TYPE_LIST:
+                       tmpl_attr_rewrite_leaf_num(map->lhs, NUM_UNSPEC, NUM_ALL);
+                       break;
 
-       default:
-               break;
-       }
+               default:
+                       break;
+               }
 
-       /*
-        *      Fixup RHS attribute references to change NUM_UNSPEC to NUM_ALL.
-        */
-       switch (map->rhs->type) {
-       case TMPL_TYPE_ATTR:
-       case TMPL_TYPE_LIST:
-               tmpl_attr_rewrite_leaf_num(map->rhs, NUM_UNSPEC, NUM_ALL);
-               break;
+               /*
+                *      Fixup RHS attribute references to change NUM_UNSPEC to NUM_ALL.
+                */
+               switch (map->rhs->type) {
+               case TMPL_TYPE_ATTR:
+               case TMPL_TYPE_LIST:
+                       tmpl_attr_rewrite_leaf_num(map->rhs, NUM_UNSPEC, NUM_ALL);
+                       break;
 
-       default:
-               break;
+               default:
+                       break;
+               }
        }
 
        /*
@@ -1807,7 +1809,7 @@ static unlang_t *compile_edit_pair(unlang_t *parent, unlang_compile_t *unlang_ct
         *      Check operators, and ensure that the RHS has been
         *      resolved.
         */
-       if (unlang_fixup_update(map, NULL) < 0) goto fail;
+       if (unlang_fixup_update(map, c) < 0) goto fail;
 
        map_list_insert_tail(&edit->maps, map);