mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-03-23 19:00:42 +01:00
cli: don't treat empty string as valid number in nmc_string_to_uint_base()
How hard can it be to use strtol()? Apparently very. You need to check errno, the endpointer, and also not pass in an empty string. Previously, nmc_string_to_uint_base() would silently accept "" as valid number. That's a bug. Btw, let's not use strtol() (or nmc_string_to_uint*()). We have _nm_utils_ascii_str_to_int64(), which gets all of this right.
This commit is contained in:
parent
b56e430da9
commit
bb4e5a7a62
1 changed files with 4 additions and 0 deletions
|
|
@ -82,6 +82,10 @@ nmc_string_to_uint_base (const char *str,
|
|||
char *end;
|
||||
unsigned long int tmp;
|
||||
|
||||
if (!str || !str[0])
|
||||
return FALSE;
|
||||
|
||||
/* FIXME: don't use this function, replace by _nm_utils_ascii_str_to_int64() */
|
||||
errno = 0;
|
||||
tmp = strtoul (str, &end, base);
|
||||
if (errno || *end != '\0' || (range_check && (tmp < min || tmp > max))) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue