comparison 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
comparison
equal deleted inserted replaced
863:14342451d3df 864:30ab30e46452
879 setrlimit(RLIMIT_CORE, &lim); 879 setrlimit(RLIMIT_CORE, &lim);
880 } 880 }
881 881
882 /* Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE, with the result in *val */ 882 /* Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE, with the result in *val */
883 int m_str_to_uint(const char* str, unsigned int *val) { 883 int m_str_to_uint(const char* str, unsigned int *val) {
884 unsigned long l;
884 errno = 0; 885 errno = 0;
885 *val = strtoul(str, NULL, 10); 886 l = strtoul(str, NULL, 10);
886 /* The c99 spec doesn't actually seem to define EINVAL, but most platforms 887 /* The c99 spec doesn't actually seem to define EINVAL, but most platforms
887 * I've looked at mention it in their manpage */ 888 * I've looked at mention it in their manpage */
888 if ((*val == 0 && errno == EINVAL) 889 if ((l == 0 && errno == EINVAL)
889 || (*val == ULONG_MAX && errno == ERANGE)) { 890 || (l == ULONG_MAX && errno == ERANGE)
891 || (l > UINT_MAX)) {
890 return DROPBEAR_FAILURE; 892 return DROPBEAR_FAILURE;
891 } else { 893 } else {
894 *val = l;
892 return DROPBEAR_SUCCESS; 895 return DROPBEAR_SUCCESS;
893 } 896 }
894 } 897 }
895 898
896 int constant_time_memcmp(const void* a, const void *b, size_t n) 899 int constant_time_memcmp(const void* a, const void *b, size_t n)