The 'up' command currently silently accepts and discards extra
characters when specifying arguments. This can produce rather
confusing behavior such as mistyping '-v -1' as '-v-1' resulting in
the '-v' switch being honored, but the '-1' being ignored. The same
thing occurs for specifying '-v1', even though the usage message
implies that you can combine arguments.
So instead, report an error message for any arguments specified that
are longer than 2 characters, since they are never valid.
Change-Id: I64846b53248ea1d06d03b6ac1fdb4317ba04b03b
Reviewed-on: http://gerrit.openafs.org/2073
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
while (argc > 0 && *argv[0] == '-') {
char *cp = *argv;
+ if (strlen(cp) > 2) {
+ goto badoption;
+ }
+
switch (*++cp) {
case 'v':
verbose = 1;
break;
default:
- fprintf(stderr, "Unknown option: '%c'\n", *cp);
+ cp--;
+
+ badoption:
+ fprintf(stderr, "Unknown option: '%s'\n", cp);
fprintf(stderr, USAGE);
exit(1);
}