From 20bdf3a5b1a1227b55a94830e5046b68b5ebc60c Mon Sep 17 00:00:00 2001 From: Matt Johnston Date: Tue, 15 Dec 2015 22:57:22 +0800 Subject: [PATCH] revert removal of space handling, different fix for avoiding option prefix matches --- cli-runopts.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/cli-runopts.c b/cli-runopts.c index 60b4aa1..ab25d37 100644 --- a/cli-runopts.c +++ b/cli-runopts.c @@ -824,22 +824,34 @@ badport: #endif static int match_extendedopt(const char** strptr, const char *optname) { + int seen_eq = 0; int optlen = strlen(optname); const char *str = *strptr; + while (isspace(*str)) { + ++str; + } + if (strncasecmp(str, optname, optlen) != 0) { return DROPBEAR_FAILURE; } str += optlen; - if (*str == '=') { - *strptr = str+1; - return DROPBEAR_SUCCESS; - } else { + while (isspace(*str) || (!seen_eq && *str == '=')) { + if (*str == '=') { + seen_eq = 1; + } + ++str; + } + + if (str-*strptr == optlen) { + /* matched just a prefix of optname */ return DROPBEAR_FAILURE; } + *strptr = str; + return DROPBEAR_SUCCESS; } static int parse_flag_value(const char *value) {