diff options
author | brian <brian@cvs.openbsd.org> | 1997-12-30 20:03:04 +0000 |
---|---|---|
committer | brian <brian@cvs.openbsd.org> | 1997-12-30 20:03:04 +0000 |
commit | 19d6af85717ead691df156728413d643dc8863d2 (patch) | |
tree | 526218992e424169635b82ed7d6808eecab3806b /usr.sbin | |
parent | 4b614fc41ae0cfe958cdbe326da894b450562b90 (diff) |
Use inet_aton() before gethostbyname()
Suggested by: Christian Sandberg <christian@yes.no>
Eivind Eklund <perhaps@yes.no>
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ppp/command.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index e06e457f7b1..f570f0dda12 100644 --- a/usr.sbin/ppp/command.c +++ b/usr.sbin/ppp/command.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: command.c,v 1.17 1997/12/30 02:45:05 brian Exp $ + * $Id: command.c,v 1.18 1997/12/30 20:03:03 brian Exp $ * */ #include <sys/param.h> @@ -1202,11 +1202,13 @@ GetIpAddr(const char *cp) struct hostent *hp; struct in_addr ipaddr; - hp = gethostbyname(cp); - if (hp && hp->h_addrtype == AF_INET) - memcpy(&ipaddr, hp->h_addr, hp->h_length); - else if (inet_aton(cp, &ipaddr) == 0) - ipaddr.s_addr = 0; + if (inet_aton(cp, &ipaddr) == 0) { + hp = gethostbyname(cp); + if (hp && hp->h_addrtype == AF_INET) + memcpy(&ipaddr, hp->h_addr, hp->h_length); + else + ipaddr.s_addr = 0; + } return (ipaddr); } |