diff options
| author | Max Horn | 2007-05-27 07:37:08 +0000 | 
|---|---|---|
| committer | Max Horn | 2007-05-27 07:37:08 +0000 | 
| commit | 33f17c57a5f9a57a85a220e11226db1caf265086 (patch) | |
| tree | f60ffd54724946a9b77f280a1887170c05946320 | |
| parent | 1f0bbd664ea30bee73c0f73e7bc35ff41469df05 (diff) | |
| download | scummvm-rg350-33f17c57a5f9a57a85a220e11226db1caf265086.tar.gz scummvm-rg350-33f17c57a5f9a57a85a220e11226db1caf265086.tar.bz2 scummvm-rg350-33f17c57a5f9a57a85a220e11226db1caf265086.zip  | |
Patch #1726251: Reject long commandline parameters that lack the option
svn-id: r26961
| -rw-r--r-- | base/commandLine.cpp | 7 | 
1 files changed, 3 insertions, 4 deletions
diff --git a/base/commandLine.cpp b/base/commandLine.cpp index 5583eed30a..5f1f7822e8 100644 --- a/base/commandLine.cpp +++ b/base/commandLine.cpp @@ -245,18 +245,17 @@ void registerDefaults() {  		} \  		const char *option = s; \  		if (*s == '\0' && !isLongCmd) { option = s2; i++; } \ -		if (!option) option = defaultVal; \ +		if (!option || *option == '\0') option = defaultVal; \  		if (option) settings[longCmd] = option;  // Use this for options which have a required (string) value  #define DO_OPTION(shortCmd, longCmd) \  	DO_OPTION_OPT(shortCmd, longCmd, 0) \ -	if (!option) usage("Option '%s' requires an argument", argv[i-1]); +	if (!option) usage("Option '%s' requires an argument", argv[isLongCmd ? i : i-1]);  // Use this for options which have a required integer value  #define DO_OPTION_INT(shortCmd, longCmd) \ -	DO_OPTION_OPT(shortCmd, longCmd, 0) \ -	if (!option) usage("Option '%s' requires an argument", argv[i-1]); \ +	DO_OPTION(shortCmd, longCmd) \  	char *endptr = 0; \  	int intValue; intValue = (int)strtol(option, &endptr, 0); \  	if (endptr == NULL || *endptr != 0) usage("--%s: Invalid number '%s'", longCmd, option);  | 
