]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
check total depth of the tree
authorAlan T. DeKok <aland@freeradius.org>
Thu, 26 Jul 2018 14:35:50 +0000 (10:35 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 26 Jul 2018 14:35:50 +0000 (10:35 -0400)
src/lib/server/command.c

index 1eab71b2344adbe28150fc832023869c69c31c4c..d95b98513c90a862deb0c8147491cc92fd9dee18 100644 (file)
@@ -698,7 +698,7 @@ int fr_command_add(TALLOC_CTX *talloc_ctx, fr_cmd_t **head, char const *name, vo
 {
        fr_cmd_t *cmd, **start;
        fr_cmd_t **insert;
-       int argc = 0;
+       int argc = 0, depth = 0;
        fr_cmd_argv_t *syntax_argv;
 
        if (name && !fr_command_valid_name(name)) {
@@ -759,6 +759,8 @@ int fr_command_add(TALLOC_CTX *talloc_ctx, fr_cmd_t **head, char const *name, vo
                        fr_strerror_printf("Commands are too deep (max is %d)", CMD_MAX_ARGV);
                        return -1;
                }
+
+               depth = i;
        }
 
        /*
@@ -798,7 +800,7 @@ int fr_command_add(TALLOC_CTX *talloc_ctx, fr_cmd_t **head, char const *name, vo
                        return  -1;
                }
 
-               if (argc == CMD_MAX_ARGV) {
+               if ((depth + argc) >= CMD_MAX_ARGV) {
                        talloc_free(syntax);
                        fr_strerror_printf("Too many arguments were supplied to the command.");
                        return  -1;