miniupnpc: Fix checking for inet_pton() errors

inet_pton() indicates error by zero or negative return value.
This commit is contained in:
Pali Rohár 2020-12-30 13:39:36 +01:00
parent 9ef311d235
commit 0d5b416e05
2 changed files with 2 additions and 2 deletions

View File

@ -62,7 +62,7 @@ int addr_is_reserved(const char * addr_str)
return 1;
#else
/* was : addr_n = inet_addr(addr_str); */
if (inet_pton(AF_INET, addr_str, &addr_n) < 0) {
if (inet_pton(AF_INET, addr_str, &addr_n) <= 0) {
/* error */
return 1;
}

View File

@ -716,7 +716,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
#endif
#else
/* was : mc_if.s_addr = inet_addr(multicastif); */ /* ex: 192.168.x.x */
if (inet_pton(AF_INET, multicastif, &mc_if.s_addr) < 0) {
if (inet_pton(AF_INET, multicastif, &mc_if.s_addr) <= 0) {
mc_if.s_addr = INADDR_NONE;
}
#endif