mirror of
https://github.com/clearml/dropbear
synced 2025-03-06 12:02:51 +00:00
Partial strings from strtoul should return error
This commit is contained in:
parent
c08177a3af
commit
110b55214b
11
dbutil.c
11
dbutil.c
@ -583,8 +583,15 @@ 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;
|
||||
l = strtoul(str, NULL, 10);
|
||||
char *endp;
|
||||
|
||||
l = strtoul(str, &endp, 10);
|
||||
|
||||
if (endp == str || *endp != '\0') {
|
||||
// parse error
|
||||
return DROPBEAR_FAILURE;
|
||||
}
|
||||
|
||||
/* The c99 spec doesn't actually seem to define EINVAL, but most platforms
|
||||
* I've looked at mention it in their manpage */
|
||||
if ((l == 0 && errno == EINVAL)
|
||||
|
Loading…
Reference in New Issue
Block a user