From ee89fb5fa3b4fe0ee5c37a7e6239b65fae36042d Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Fri, 29 Dec 2023 23:59:28 +0100 Subject: [PATCH] obsdrdr.c: check errors of inet_ntop() --- miniupnpd/pf/obsdrdr.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/miniupnpd/pf/obsdrdr.c b/miniupnpd/pf/obsdrdr.c index e9e05aa..5d323e1 100644 --- a/miniupnpd/pf/obsdrdr.c +++ b/miniupnpd/pf/obsdrdr.c @@ -1473,7 +1473,10 @@ update_portmapping(const char * ifname, unsigned short eport, int proto, if (priv_delete_filter_rule(ifname, old_iport, proto, iaddr) < 0) return -1; - inet_ntop(AF_INET, &iaddr, iaddr_str, sizeof(iaddr_str)); + if (inet_ntop(AF_INET, &iaddr, iaddr_str, sizeof(iaddr_str)) == NULL) { + syslog(LOG_ERR, "inet_ntop(AF_INET, ...): %m"); + return -1; + } if(add_redirect_rule2(ifname, rhost, eport, iaddr_str, iport, proto, desc, timestamp) < 0) @@ -1508,7 +1511,10 @@ update_portmapping_desc_timestamp(const char * ifname, if (priv_delete_filter_rule(ifname, iport, proto, iaddr) < 0) return -1; - inet_ntop(AF_INET, &iaddr, iaddr_str, sizeof(iaddr_str)); + if (inet_ntop(AF_INET, &iaddr, iaddr_str, sizeof(iaddr_str)) == NULL) { + syslog(LOG_ERR, "inet_ntop(AF_INET, ...): %m"); + return -1; + } if(add_redirect_rule2(ifname, rhost, eport, iaddr_str, iport, proto, desc, timestamp) < 0)