--- src/sbin/mount_nfs/mount_nfs.c 2006/03/27 16:18:13 1.12 +++ src/sbin/mount_nfs/mount_nfs.c 2008/02/16 20:49:28 1.12.8.1 @@ -559,6 +559,7 @@ getnfsargs(char *spec, struct nfs_args * { struct hostent *hp; struct sockaddr_in saddr; + struct in_addr iaddr; enum tryret ret; int speclen, remoteerr; char *hostp, *delimp, *errstr; @@ -630,12 +631,16 @@ getnfsargs(char *spec, struct nfs_args * _res.retrans = 3; break; } - if (isdigit(*hostp)) { - saddr.sin_addr.s_addr = inet_addr(hostp); - if (saddr.sin_addr.s_addr == INADDR_NONE) { - warnx("bad net address %s", hostp); - haserror = EAI_FAIL; - } + if (inet_aton(hostp, &iaddr)) { + if ((hp = gethostbyaddr((char *) &iaddr, + sizeof(iaddr), + AF_INET)) != NULL) { + memmove(&saddr.sin_addr, hp->h_addr, + MIN(hp->h_length, (int)sizeof(saddr.sin_addr))); + } else { + warnx("bad net address %s", hostp); + haserror = EAI_FAIL; + } } else if ((hp = gethostbyname(hostp)) != NULL) { memmove(&saddr.sin_addr, hp->h_addr, MIN(hp->h_length, (int)sizeof(saddr.sin_addr)));