# HG changeset patch # User Matt Johnston # Date 1450191442 -28800 # Node ID de2e39e94c680b601e9295e986d0687181ab975e # Parent b73c078e11e99ae4cbd249a6329a7b9a56b1a4bf revert removal of space handling, different fix for avoiding option prefix matches diff -r b73c078e11e9 -r de2e39e94c68 cli-runopts.c --- a/cli-runopts.c Tue Dec 15 22:23:42 2015 +0800 +++ b/cli-runopts.c Tue Dec 15 22:57:22 2015 +0800 @@ -824,22 +824,34 @@ #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) {