提交 5ea412e4 编写于 作者: L LiuHao

check invalid argument

Signed-off-by: NLiuHao <liuhao27@huawei.com>
上级 6dad59d6
......@@ -124,6 +124,9 @@ static int do_parse_ipnet(const char *cidr_str, const char *ip_str, uint8_t **ip
ERROR("Parse cidr failed: %s", *err != NULL ? *err : "");
return -1;
}
if (ip_str == NULL) {
return 0;
}
ret = parse_ip_from_str(ip_str, ip, ip_len, err);
if (ret != 0) {
ERROR("Parse ip failed: %s", *err != NULL ? *err : "");
......
......@@ -645,6 +645,10 @@ static int do_parse_ipv6_from_str(const char *addr, struct in6_addr *ipv6, uint8
{
int nret = 0;
if (addr == NULL) {
ERROR("Empty address");
return -1;
}
nret = inet_pton(AF_INET6, addr, ipv6);
if (nret < 0) {
nret = asprintf(err, "ipv6 inet_pton %s", strerror(errno));
......@@ -674,6 +678,10 @@ int parse_ip_from_str(const char *addr, uint8_t **ips, size_t *len, char **err)
struct in6_addr ipv6;
int ret = -1;
if (addr == NULL) {
ERROR("Empty address");
return -1;
}
nret = inet_pton(AF_INET, addr, &ipv4);
if (nret < 0) {
nret = asprintf(err, "ipv4 inet_pton %s", strerror(errno));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册