From c09f4854829a7c9ac649ce61f9630fac50061019 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Mon, 1 Jun 2020 17:56:38 +0200 Subject: [PATCH] nftnlrdr.c: fix writing to iaddr instead of rhost fixes #462 https://github.com/miniupnp/miniupnp/issues/462 https://github.com/miniupnp/miniupnp/issues/459#issuecomment-636402954 --- miniupnpd/netfilter_nft/nftnlrdr.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/miniupnpd/netfilter_nft/nftnlrdr.c b/miniupnpd/netfilter_nft/nftnlrdr.c index 4fe4c36..193b9cf 100644 --- a/miniupnpd/netfilter_nft/nftnlrdr.c +++ b/miniupnpd/netfilter_nft/nftnlrdr.c @@ -462,9 +462,13 @@ get_peer_rule_by_index(int index, } if (iaddr != NULL) { + /* TODO : use inet_ntop() instead of inet_ntoa() */ + /* char * inet_ntoa(struct in_addr in); */ + /* const char * inet_ntop(int af, const void * restrict src, char * restrict dst, socklen_t size) */ addr.s_addr = r->iaddr; addr_str = inet_ntoa(addr); strncpy(iaddr , addr_str, iaddrlen); + /* inet_ntop(AF_INET, &r->iaddr, iaddr, iaddrlen) */ } if (iport != NULL) { @@ -478,7 +482,7 @@ get_peer_rule_by_index(int index, if (rhost != NULL) { addr.s_addr = r->rhost; addr_str = inet_ntoa(addr); - strncpy(iaddr , addr_str, rhostlen); + strncpy(rhost, addr_str, rhostlen); } if (rport != NULL) { @@ -574,7 +578,7 @@ get_redirect_rule_by_index(int index, if (rhost != NULL) { addr.s_addr = r->rhost; addr_str = inet_ntoa(addr); - strncpy(iaddr , addr_str, rhostlen); + strncpy(rhost, addr_str, rhostlen); } if (desc != NULL && r->desc) {