net: utils: Check null pointer when parsing IPv6 address
We might access NULL pointer if strchr() return value is not checked properly. Coverity-CID: 187073 Fixes #8993 Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
dfa3f10b26
commit
7f0432a114
|
@ -309,11 +309,14 @@ int net_addr_pton(sa_family_t family, const char *src,
|
|||
UNALIGNED_PUT(htons(strtol(src, NULL, 16)),
|
||||
&addr->s6_addr16[i]);
|
||||
src = strchr(src, ':');
|
||||
if (!src && i < expected_groups - 1) {
|
||||
return -EINVAL;
|
||||
if (src) {
|
||||
src++;
|
||||
} else {
|
||||
if (i < expected_groups - 1) {
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
src++;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -363,11 +366,13 @@ int net_addr_pton(sa_family_t family, const char *src,
|
|||
addr->s6_addr[12 + i] = strtol(src, NULL, 10);
|
||||
|
||||
src = strchr(src, '.');
|
||||
if (!src && i < 3) {
|
||||
return -EINVAL;
|
||||
if (src) {
|
||||
src++;
|
||||
} else {
|
||||
if (i < 3) {
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
src++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue