diff options
author | cjc <cjc@FreeBSD.org> | 2002-08-25 05:44:13 +0000 |
---|---|---|
committer | cjc <cjc@FreeBSD.org> | 2002-08-25 05:44:13 +0000 |
commit | e4a8f19dec8e7787e97565378dda14ef8f6ea854 (patch) | |
tree | 73548c065a14e4c9c3345f381ffd5c472081841a /sbin | |
parent | d5f256dae2732558d27849edcff2edd6ee0fc897 (diff) | |
download | FreeBSD-src-e4a8f19dec8e7787e97565378dda14ef8f6ea854.zip FreeBSD-src-e4a8f19dec8e7787e97565378dda14ef8f6ea854.tar.gz |
Check if a host argument is a IPv6 presentation format address before
going to gethostbyname2(3).
PR: bin/31632
MFC after: 3 days
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/ip6fw/ip6fw.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/sbin/ip6fw/ip6fw.c b/sbin/ip6fw/ip6fw.c index 9f14540..7069e5b 100644 --- a/sbin/ip6fw/ip6fw.c +++ b/sbin/ip6fw/ip6fw.c @@ -548,13 +548,13 @@ lookup_host (host, addr, family) char *host; u_char *addr; { - struct hostent *he = gethostbyname2(host, family); - - if (!he) - return(-1); - - memcpy(addr, he->h_addr_list[0], he->h_length); + struct hostent *he; + if (inet_pton(family, host, addr) != 1) { + if ((he = gethostbyname2(host, family)) == NULL) + return(-1); + memcpy(addr, he->h_addr_list[0], he->h_length); + } return(0); } |