diff options
author | 2018-04-10 14:37:08 +0000 | |
---|---|---|
committer | 2018-04-10 14:37:08 +0000 | |
commit | f5d7b76b0d6d2a1c1362d41bbc7da795b84537a0 (patch) | |
tree | 425d6035e0d58f422ac4cd4db5257091237cd526 | |
parent | Fix stop condition for linear search by taking into account the search (diff) | |
download | wireguard-openbsd-f5d7b76b0d6d2a1c1362d41bbc7da795b84537a0.tar.xz wireguard-openbsd-f5d7b76b0d6d2a1c1362d41bbc7da795b84537a0.zip |
Fix previous. Use inet_net_pton(3) instead of inet_pton(3) as
addresses could be listed with prefix.
Initial diff from Ryan Kavanagh, tweaked by me.
Ok millert@ gilles@
-rw-r--r-- | usr.sbin/smtpd/spfwalk.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/usr.sbin/smtpd/spfwalk.c b/usr.sbin/smtpd/spfwalk.c index a9c21ef8974..cc9ed09240d 100644 --- a/usr.sbin/smtpd/spfwalk.c +++ b/usr.sbin/smtpd/spfwalk.c @@ -14,11 +14,13 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <sys/types.h> #include <sys/socket.h> #include <sys/tree.h> #include <arpa/inet.h> #include <arpa/nameser.h> +#include <netinet/in.h> #include <netdb.h> #include <asr.h> @@ -170,25 +172,29 @@ dispatch_txt(struct dns_rr *rr) if (strncasecmp("ip4:", *ap, 4) == 0) { if ((ip_v4 == 1 || ip_both == 1) && - inet_pton(AF_INET, *(ap) + 4, &ina) == 1) + inet_net_pton(AF_INET, *(ap) + 4, + &ina, sizeof(ina)) != -1) printf("%s\n", *(ap) + 4); continue; } if (strncasecmp("ip6:", *ap, 4) == 0) { if ((ip_v6 == 1 || ip_both == 1) && - inet_pton(AF_INET6, *(ap) + 4, &ina) == 1) + inet_net_pton(AF_INET6, *(ap) + 4, + &ina, sizeof(ina)) != -1) printf("%s\n", *(ap) + 4); continue; } if (strncasecmp("+ip4:", *ap, 5) == 0) { if ((ip_v4 == 1 || ip_both == 1) && - inet_pton(AF_INET, *(ap) + 5, &ina) == 1) + inet_net_pton(AF_INET, *(ap) + 5, + &ina, sizeof(ina)) != -1) printf("%s\n", *(ap) + 5); continue; } if (strncasecmp("+ip6:", *ap, 5) == 0) { if ((ip_v6 == 1 || ip_both == 1) && - inet_pton(AF_INET6, *(ap) + 5, &ina) == 1) + inet_net_pton(AF_INET6, *(ap) + 5, + &ina, sizeof(ina)) != -1) printf("%s\n", *(ap) + 5); continue; } |