iptpinhole.c: check inet_pton() return values
This commit is contained in:
parent
51f185fd13
commit
fda61180e0
|
@ -229,11 +229,17 @@ int add_pinhole(const char * ifname,
|
|||
if(ifname)
|
||||
strncpy(e->ipv6.iniface, ifname, IFNAMSIZ);
|
||||
if(rem_host && (rem_host[0] != '\0')) {
|
||||
inet_pton(AF_INET6, rem_host, &e->ipv6.src);
|
||||
memset(&e->ipv6.smsk, 0xff, sizeof(e->ipv6.smsk));
|
||||
if(inet_pton(AF_INET6, rem_host, &e->ipv6.src) < 1) {
|
||||
syslog(LOG_WARNING, "failed to parse INET6 address \"%s\"", rem_host);
|
||||
} else {
|
||||
memset(&e->ipv6.smsk, 0xff, sizeof(e->ipv6.smsk));
|
||||
}
|
||||
}
|
||||
if (inet_pton(AF_INET6, int_client, &e->ipv6.dst) < 1) {
|
||||
syslog(LOG_WARNING, "failed to parse INET6 address \"%s\"", int_client);
|
||||
} else {
|
||||
memset(&e->ipv6.dmsk, 0xff, sizeof(e->ipv6.dmsk));
|
||||
}
|
||||
inet_pton(AF_INET6, int_client, &e->ipv6.dst);
|
||||
memset(&e->ipv6.dmsk, 0xff, sizeof(e->ipv6.dmsk));
|
||||
|
||||
/*e->nfcache = NFC_IP_DST_PT;*/
|
||||
/*e->nfcache |= NFC_UNKNOWN;*/
|
||||
|
@ -286,11 +292,17 @@ find_pinhole(const char * ifname,
|
|||
UNUSED(ifname);
|
||||
|
||||
if(rem_host && (rem_host[0] != '\0')) {
|
||||
inet_pton(AF_INET6, rem_host, &saddr);
|
||||
if (inet_pton(AF_INET6, rem_host, &saddr) < 1) {
|
||||
syslog(LOG_WARNING, "Failed to parse INET6 address \"%s\"", rem_host);
|
||||
memset(&saddr, 0, sizeof(struct in6_addr));
|
||||
}
|
||||
} else {
|
||||
memset(&saddr, 0, sizeof(struct in6_addr));
|
||||
}
|
||||
inet_pton(AF_INET6, int_client, &daddr);
|
||||
if (inet_pton(AF_INET6, int_client, &daddr) < 1) {
|
||||
syslog(LOG_WARNING, "Failed to parse INET6 address \"%s\"", int_client);
|
||||
memset(&daddr, 0, sizeof(struct in6_addr));
|
||||
}
|
||||
for(p = pinhole_list.lh_first; p != NULL; p = p->entries.le_next) {
|
||||
if((proto == p->proto) && (rem_port == p->sport) &&
|
||||
(0 == memcmp(&saddr, &p->saddr, sizeof(struct in6_addr))) &&
|
||||
|
|
Loading…
Reference in New Issue