From a2f3be5265a9e8a7f2cf0dd751a9ab82d289cef8 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 3 Jun 2010 09:54:28 -0500 Subject: [PATCH] up: refuse multicharacter arguments 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 Reviewed-by: Jeffrey Altman Reviewed-by: Derrick Brashear --- src/venus/up.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/venus/up.c b/src/venus/up.c index 782075550..8663a19c8 100644 --- a/src/venus/up.c +++ b/src/venus/up.c @@ -125,6 +125,10 @@ ScanArgs(int argc, char *argv[]) while (argc > 0 && *argv[0] == '-') { char *cp = *argv; + if (strlen(cp) > 2) { + goto badoption; + } + switch (*++cp) { case 'v': verbose = 1; @@ -151,7 +155,10 @@ ScanArgs(int argc, char *argv[]) break; default: - fprintf(stderr, "Unknown option: '%c'\n", *cp); + cp--; + + badoption: + fprintf(stderr, "Unknown option: '%s'\n", cp); fprintf(stderr, USAGE); exit(1); } -- 2.39.5