]> andersk Git - moira.git/commitdiff
Don't crash if given more than MAXARGS arguments.
authorzacheiss <zacheiss>
Mon, 27 Aug 2007 15:22:15 +0000 (15:22 +0000)
committerzacheiss <zacheiss>
Mon, 27 Aug 2007 15:22:15 +0000 (15:22 +0000)
clients/mrtest/mrtest.c

index 127e4d62df64b040908c511b131ff5d656414963..6055b7f9cb9cecac43f091a968688d4fcb6f156e 100644 (file)
@@ -259,8 +259,14 @@ int parse(char *buf, char *argv[MAXARGS])
          /* skip whitespace */
          for (*p++ = '\0'; *p == ' ' || *p == '\t'; p++)
            ;
-         if (*p && *p != '\n')
-           argv[++argc] = p--;
+         if (*p && *p != '\n') {
+           if (++argc >= MAXARGS) {
+             fprintf(stderr,
+                     "moira: Too many command line arguments\n");
+             return 0;
+           }
+           argv[argc] = p--;
+         }
        }
     }
   if (*p == '\n')
This page took 0.042394 seconds and 5 git commands to generate.