diff options
author | Matt Johnston <matt@ucc.asn.au> | 2013-11-25 23:08:33 +0800 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2013-11-25 23:08:33 +0800 |
commit | c5e36f8e3cd390b77ce43f58f01b3d3a9111d989 (patch) | |
tree | 0924f43a4cf93bd6211e36117441165fdfb71e75 /dbutil.c | |
parent | 5a85c4b91b8f602f325fbdea2adc697c50c1630f (diff) |
Fix some warnings
Diffstat (limited to 'dbutil.c')
-rw-r--r-- | dbutil.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -881,14 +881,17 @@ void disallow_core() { /* 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; } } |