]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
move regex sanity checks to map_afrom_substr()
authorAlan T. DeKok <aland@freeradius.org>
Tue, 27 Apr 2021 13:15:24 +0000 (09:15 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 27 Apr 2021 13:15:24 +0000 (09:15 -0400)
src/lib/server/map.c
src/lib/server/users_file.c

index f1ec2c78b32107a47391b1dfe9be8e6b464935f3..3530aa5290c18abbee541705c3874b46c994563f 100644 (file)
@@ -438,6 +438,26 @@ ssize_t map_afrom_substr(TALLOC_CTX *ctx, map_t **out, fr_sbuff_t *in,
                }
        }
 
+       if (tmpl_contains_regex(map->lhs)) {
+               fr_sbuff_set(&our_in, &m_lhs);
+               fr_strerror_const("Unexpected regular expression");
+               goto error;
+       }
+
+       if ((map->op == T_OP_REG_EQ) || (map->op == T_OP_REG_NE)) {
+               if (!tmpl_contains_regex(map->rhs)) {
+                       fr_sbuff_set(&our_in, &m_rhs);
+                       fr_strerror_const("Expected regular expression after regex operator");
+                       goto error;
+               }
+       } else {
+               if (tmpl_contains_regex(map->rhs)) {
+                       fr_sbuff_set(&our_in, &m_rhs);
+                       fr_strerror_const("Unexpected regular expression");
+                       goto error;
+               }
+       }
+
        MAP_VERIFY(map);
        *out = map;
 
index bf20496e4526f38ebd5de287357a71ecbbba00d3..9699e835ec868ccfe1564640cf0e6acdbb995ccc 100644 (file)
@@ -442,13 +442,6 @@ check_item:
                }
 
                if (tmpl_contains_regex(new_map->rhs)) {
-                       if (!((new_map->op == T_OP_REG_EQ) ||
-                             (new_map->op == T_OP_REG_NE))) {
-                               ERROR("%s[%d]: Unexpected regular expression on RHS of check item",
-                                     file, line);
-                               goto fail_entry;
-                       }
-
                        /*
                         *      The default rules say that the check
                         *      items look at the control list, but