diff dbutil.c @ 864:30ab30e46452

Fix some warnings
author Matt Johnston <matt@ucc.asn.au>
date Mon, 25 Nov 2013 23:08:33 +0800
parents 4095b6d7c9fc
children 80af450dae76
line wrap: on
line diff
--- a/dbutil.c	Thu Nov 14 22:39:27 2013 +0800
+++ b/dbutil.c	Mon Nov 25 23:08:33 2013 +0800
@@ -881,14 +881,17 @@
 
 /* Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE, with the result in *val */
 int m_str_to_uint(const char* str, unsigned int *val) {
+	unsigned long l;
 	errno = 0;
-	*val = strtoul(str, NULL, 10);
+	l = strtoul(str, NULL, 10);
 	/* The c99 spec doesn't actually seem to define EINVAL, but most platforms
 	 * I've looked at mention it in their manpage */
-	if ((*val == 0 && errno == EINVAL)
-		|| (*val == ULONG_MAX && errno == ERANGE)) {
+	if ((l == 0 && errno == EINVAL)
+		|| (l == ULONG_MAX && errno == ERANGE)
+		|| (l > UINT_MAX)) {
 		return DROPBEAR_FAILURE;
 	} else {
+		*val = l;
 		return DROPBEAR_SUCCESS;
 	}
 }