diff cli-runopts.c @ 1256:506f7681d0f8 coverity

merge up to date
author Matt Johnston <matt@ucc.asn.au>
date Tue, 15 Mar 2016 22:45:43 +0800
parents 888e3d17e962
children 968be6f7cff6
line wrap: on
line diff
--- a/cli-runopts.c	Tue Dec 15 22:24:34 2015 +0800
+++ b/cli-runopts.c	Tue Mar 15 22:45:43 2016 +0800
@@ -538,7 +538,7 @@
 
 	if (opts.recv_window != DEFAULT_RECV_WINDOW)
 	{
-		int written = snprintf(ret+total, len-total, "-W %d ", opts.recv_window);
+		int written = snprintf(ret+total, len-total, "-W %u ", opts.recv_window);
 		total += written;
 	}
 
@@ -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) {