]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
account for "name", which uses one argc
authorAlan T. DeKok <aland@freeradius.org>
Thu, 28 Jun 2018 21:32:14 +0000 (17:32 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 30 Jun 2018 13:07:44 +0000 (09:07 -0400)
src/main/command.c

index dcff00732759a3cf4e39c1277f14f197fc6a7859..f1d44a957a667d29e5d721e56d675ac73441f1be 100644 (file)
@@ -911,8 +911,8 @@ int fr_command_run(FILE *fp, fr_cmd_t *head, int argc, char const *argv[])
                 *      @todo - allow varargs
                 *      @todo - return which argument was broken?
                 */
-               if (argc != (i + cmd->syntax_argc)) {
-                       fr_strerror_printf("Input has too many or too few parameters for command.");
+               if (argc != (i + 1 + cmd->syntax_argc)) {
+                       fr_strerror_printf("Input has too many or too few parameters for command");
                        return -1;
                }
 
@@ -922,6 +922,7 @@ int fr_command_run(FILE *fp, fr_cmd_t *head, int argc, char const *argv[])
                for (j = 0; j < cmd->syntax_argc; j++) {
                        fr_value_box_t box;
                        char quote;
+                       int offset = i + 1 + j;
 
                        if (cmd->syntax_types[j] == FR_TYPE_INVALID) {
                                continue;
@@ -929,9 +930,9 @@ int fr_command_run(FILE *fp, fr_cmd_t *head, int argc, char const *argv[])
 
                        quote = '\0';
                        if (cmd->syntax_types[j] == FR_TYPE_STRING) {
-                               if ((argv[i + j][0] == '"') ||
-                                   (argv[i + j][0] == '\'')) {
-                                       quote = argv[i + j][0];
+                               if ((argv[offset][0] == '"') ||
+                                   (argv[offset][0] == '\'')) {
+                                       quote = argv[offset][0];
                                }
                        }
 
@@ -939,8 +940,8 @@ int fr_command_run(FILE *fp, fr_cmd_t *head, int argc, char const *argv[])
                         *      Parse the data to be sure it's well formed.
                         */
                        if (fr_value_box_from_str(NULL, &box, &cmd->syntax_types[j],
-                                                 NULL, argv[i + j], -1, quote, true) < 0) {
-                               return -(i + j);
+                                                 NULL, argv[offset], -1, quote, true) < 0) {
+                               return -(offset);
                        }
 
                        fr_value_box_clear(&box);