]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fixed reporting of malformed -n values on the command line.
authorAlex Rousskov <rousskov@measurement-factory.com>
Mon, 11 Aug 2014 17:29:47 +0000 (11:29 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Mon, 11 Aug 2014 17:29:47 +0000 (11:29 -0600)
Test case: $ squid -n ' '
FATAL: Expected alphanumeric service name for the -n option but got: squid

src/main.cc

index d2e71b91097af4a47346ff001dec600d2a435cbb..177b3625a980015c107d19561a652f72f2433122 100644 (file)
@@ -511,8 +511,10 @@ mainParseOptions(int argc, char *argv[])
                 const SBuf t(optarg);
                 ::Parser::Tokenizer tok(t);
                 const CharacterSet chr = CharacterSet::ALPHA+CharacterSet::DIGIT;
-                if (!tok.prefix(service_name, chr) || !tok.atEnd())
-                    fatalf("Expected alphanumeric service name for the -n option but got: " SQUIDSBUFPH, SQUIDSBUFPRINT(service_name));
+                if (!tok.prefix(service_name, chr))
+                    fatalf("Expected alphanumeric service name for the -n option but got: %s", optarg);
+                if (!tok.atEnd())
+                    fatalf("Garbage after alphanumeric service name in the -n option value: %s", optarg);
                 if (service_name.length() > 32)
                     fatalf("Service name (-n option) must be limited to 32 characters but got %u", service_name.length());
                 opt_signal_service = true;