From 9cd53915353efd110116ef38493301bb053f0f79 Mon Sep 17 00:00:00 2001 From: mycroft Date: Sun, 21 May 1995 15:33:22 +0000 Subject: [PATCH] Use inet_aton(), not inet_addr(). --- sbin/mount_portal/pt_tcp.c | 11 +++++------ usr.bin/ypwhich/ypwhich.c | 22 +++++++++++----------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/sbin/mount_portal/pt_tcp.c b/sbin/mount_portal/pt_tcp.c index 447790a0683b..ee9b97fd68e7 100644 --- a/sbin/mount_portal/pt_tcp.c +++ b/sbin/mount_portal/pt_tcp.c @@ -1,4 +1,4 @@ -/* $NetBSD: pt_tcp.c,v 1.8 1995/04/23 10:33:27 cgd Exp $ */ +/* $NetBSD: pt_tcp.c,v 1.9 1995/05/21 15:33:22 mycroft Exp $ */ /* * Copyright (c) 1992, 1993 @@ -106,13 +106,12 @@ int *fdp; } } - hp = gethostbyname(host); - if (hp != 0) { + if (inet_aton(host, &ina) == 0) { + hp = gethostbyname(host); + if (hp == 0) + return (EINVAL); ipp = (struct in_addr **) hp->h_addr_list; } else { - ina.s_addr = inet_addr(host); - if (ina.s_addr == INADDR_NONE) - return (EINVAL); ip[0] = &ina; ip[1] = 0; ipp = ip; diff --git a/usr.bin/ypwhich/ypwhich.c b/usr.bin/ypwhich/ypwhich.c index 42313bffa399..00b529e200f4 100644 --- a/usr.bin/ypwhich/ypwhich.c +++ b/usr.bin/ypwhich/ypwhich.c @@ -31,7 +31,7 @@ */ #ifndef LINT -static char rcsid[] = "$Id: ypwhich.c,v 1.3 1994/05/25 09:55:02 deraadt Exp $"; +static char rcsid[] = "$Id: ypwhich.c,v 1.4 1995/05/21 15:40:43 mycroft Exp $"; #endif #include @@ -129,8 +129,6 @@ char **argv; { char *domainname, *master, *map; struct ypmaplist *ypml, *y; - extern char *optarg; - extern int optind; struct hostent *hent; struct sockaddr_in sin; int notrans, mode, getmap; @@ -160,9 +158,11 @@ char **argv; default: usage(); } + argc -= optind; + argv += optind; if(mode==0) { - switch(argc-optind) { + switch(argc) { case 0: bzero(&sin, sizeof sin); sin.sin_family = AF_INET; @@ -174,14 +174,14 @@ char **argv; case 1: bzero(&sin, sizeof sin); sin.sin_family = AF_INET; - if( (sin.sin_addr.s_addr=inet_addr(argv[optind]))==-1) { - hent = gethostbyname(argv[optind]); + if (inet_aton(argv[0], &sin.sin_addr) == 0) { + hent = gethostbyname(argv[0]); if(!hent) { fprintf(stderr, "ypwhich: host %s unknown\n", - argv[optind]); + argv[0]); exit(1); } - bcopy((char *)hent->h_addr_list[0], + bcopy((char *)hent->h_addr, (char *)&sin.sin_addr, sizeof sin.sin_addr); } if(bind_host(domainname, &sin)) @@ -193,11 +193,11 @@ char **argv; exit(0); } - if( argc-optind > 1) + if( argc > 1) usage(); - if(argv[optind]) { - map = argv[optind]; + if(argv[0]) { + map = argv[0]; for(i=0; (!notrans) && i