]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
support nested optional strings
authorAlan T. DeKok <aland@freeradius.org>
Thu, 5 Jul 2018 13:22:12 +0000 (09:22 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 5 Jul 2018 15:34:53 +0000 (11:34 -0400)
src/main/command.c

index 95c3147962633583a3b1e2cb9659f159363748aa..dd90db8090429604090220e1498b03e2d65cbaaf 100644 (file)
@@ -324,6 +324,7 @@ static int split(char **input, char **output, bool syntax_string)
        } else if (syntax_string && ((*str == '[') || (*str == '('))) {
                char end;
                quote = *(str++);
+               int count = 0;
 
                if (quote == '[') {
                        end = ']';
@@ -336,16 +337,14 @@ static int split(char **input, char **output, bool syntax_string)
                 *      only for parsing syntax strings, which CANNOT
                 *      have quotes in them.
                 */
-               while (*str != end) {
+               while ((*str != end) || (count > 0)) {
                        if (!*str) {
                                fr_strerror_printf("String ends before closing brace.");
                                return -1;
                        }
 
-                       if (*str == quote) {
-                               fr_strerror_printf("Nested braces are not allowed.");
-                               return -1;
-                       }
+                       if (*str == quote) count++;
+                       if (*str == end) count--;
 
                        str++;
                }