]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
make conditional parser check for regexes, too
authorAlan T. DeKok <aland@freeradius.org>
Wed, 11 Sep 2019 16:54:22 +0000 (12:54 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 11 Sep 2019 19:08:58 +0000 (15:08 -0400)
if tmpl_preparse() is told to not require a regex, then it should
treat '/' as any other character

src/lib/server/cond_tokenize.c
src/lib/server/tmpl.c

index 1f6ae113fc169b75cda2393130f1ccc27975b007..5f1ebbfdddb4d7d96b21cf21d07f651273fb8af4 100644 (file)
@@ -581,6 +581,18 @@ static ssize_t cond_preparse(TALLOC_CTX *ctx, char const **out, size_t *outlen,
        char *p, *expanded;
        char buffer[8192];
 
+        /*
+        *      When 'request_regex == false', tmpl_preparse() treats
+        *      '/' as a bare word.  This is so that the configuration
+        *      file parser can parse filenames, which may begin with
+        *      '/'.  We therefore check for leading '/' here, as
+        *      conditions don't use filenames.
+        */
+       if (!require_regex && (*start == '/')) {
+               *error = "Unexpected regular expression";
+               return 0;
+       }
+
        /*
         *      Allow dynamic xlat expansion everywhere.
         */
index ac323149938332ddbc0963d902b6903180669177..99c11986f7b2eb97caeb6e180214cb219a97f62a 100644 (file)
@@ -2994,10 +2994,7 @@ ssize_t tmpl_preparse(char const **out, size_t *outlen, char const *start,
                if (*p != '/') {
                        return_P("Expected regular expression");
                }
-
-       } else if (*p == '/') {
-               return_P("Unexpected regular expression");
-       }
+       } /* else treat '/' as any other character */
 
        switch (*p) {
                /*