From 0d5b416e0535019a2edb4017f43b3d8adc665a93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Wed, 30 Dec 2020 13:39:36 +0100 Subject: [PATCH] miniupnpc: Fix checking for inet_pton() errors inet_pton() indicates error by zero or negative return value. --- miniupnpc/addr_is_reserved.c | 2 +- miniupnpc/minissdpc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/miniupnpc/addr_is_reserved.c b/miniupnpc/addr_is_reserved.c index 046380e..411b12e 100644 --- a/miniupnpc/addr_is_reserved.c +++ b/miniupnpc/addr_is_reserved.c @@ -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; } diff --git a/miniupnpc/minissdpc.c b/miniupnpc/minissdpc.c index 7f68fc5..8d51d6f 100644 --- a/miniupnpc/minissdpc.c +++ b/miniupnpc/minissdpc.c @@ -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