mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-22 23:09:34 +01:00
netconfig: Fix address format validation
Drop the wrong negation in the error check. Check that there are no extra characters after prefix length suffix. Reset errno 0 before the strtoul call, as recommended by the manpage.
This commit is contained in:
parent
ef956995b8
commit
ba1253df3b
@ -515,6 +515,7 @@ static struct l_rtnl_address *netconfig_get_static6_address(
|
|||||||
{
|
{
|
||||||
L_AUTO_FREE_VAR(char *, ip);
|
L_AUTO_FREE_VAR(char *, ip);
|
||||||
char *p;
|
char *p;
|
||||||
|
char *endp;
|
||||||
struct l_rtnl_address *ret;
|
struct l_rtnl_address *ret;
|
||||||
uint32_t prefix_len = 128;
|
uint32_t prefix_len = 128;
|
||||||
|
|
||||||
@ -530,8 +531,9 @@ static struct l_rtnl_address *netconfig_get_static6_address(
|
|||||||
if (*++p == '\0')
|
if (*++p == '\0')
|
||||||
goto no_prefix_len;
|
goto no_prefix_len;
|
||||||
|
|
||||||
prefix_len = strtoul(p, NULL, 10);
|
errno = 0;
|
||||||
if (!unlikely(errno == EINVAL || errno == ERANGE ||
|
prefix_len = strtoul(p, &endp, 10);
|
||||||
|
if (unlikely(*endp != '\0' || errno ||
|
||||||
!prefix_len || prefix_len > 128)) {
|
!prefix_len || prefix_len > 128)) {
|
||||||
l_error("netconfig: Invalid prefix '%s' provided in network"
|
l_error("netconfig: Invalid prefix '%s' provided in network"
|
||||||
" configuration file", p);
|
" configuration file", p);
|
||||||
|
Loading…
Reference in New Issue
Block a user