Download raw body.
mount_nfs(8): get rid of inet_aton.
On Sun, Aug 18, 2024 at 03:10:32PM +0200, Florian Obser wrote:
> I doubt anyone needs inet_aton's flexibility^W impreciseness.
>
> OK?
OK bluhm@
> diff --git mount_nfs.c mount_nfs.c
> index 1c2ecf8fbaa..0724936f0b3 100644
> --- mount_nfs.c
> +++ mount_nfs.c
> @@ -383,7 +383,7 @@ int
> getnfsargs(char *spec, struct nfs_args *nfsargsp)
> {
> CLIENT *clp;
> - struct hostent *hp;
> + struct addrinfo hints, *res;
> static struct sockaddr_in saddr;
> struct timeval pertry, try;
> enum clnt_stat clnt_stat;
> @@ -411,14 +411,15 @@ getnfsargs(char *spec, struct nfs_args *nfsargsp)
> /*
> * Handle an internet host address
> */
> - if (inet_aton(hostp, &saddr.sin_addr) == 0) {
> - hp = gethostbyname(hostp);
> - if (hp == NULL) {
> - warnx("can't resolve address for host %s", hostp);
> - return (0);
> - }
> - memcpy(&saddr.sin_addr, hp->h_addr, hp->h_length);
> + memset(&hints, 0, sizeof(hints));
> + hints.ai_family = AF_INET;
> +
> + if (getaddrinfo(hostp, NULL, &hints, &res) != 0) {
> + warnx("can't resolve address for host %s", hostp);
> + return (0);
> }
> + saddr.sin_addr = ((struct sockaddr_in *)res->ai_addr)->sin_addr;
> + freeaddrinfo(res);
>
> if (force2) {
> nfsvers = NFS_VER2;
>
> --
> In my defence, I have been left unsupervised.
mount_nfs(8): get rid of inet_aton.