From 9a5228b9a7c6b7ed7ccb13e4ffabf7b27006cc46 Mon Sep 17 00:00:00 2001 From: Florian Obser Date: Mon, 19 Sep 2016 07:08:31 +0000 Subject: Only allow standard dot notation for IPv4 addresses. We can get rid of inet_aton(3) and use the AF independent getaddrinfo(3). OK natano@, krw@, millert@, claudio@ --- sbin/ping/ping.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'sbin') diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index 613e600a464..c8cfb8d0384 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ping.c,v 1.212 2016/09/18 17:27:25 florian Exp $ */ +/* $OpenBSD: ping.c,v 1.213 2016/09/19 07:08:30 florian Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -427,12 +427,7 @@ main(int argc, char *argv[]) memset(&dst4, 0, sizeof(dst4)); memset(&dst6, 0, sizeof(dst6)); - if (inet_aton(*argv, &dst4.sin_addr) != 0) { - hostname = *argv; - if ((target = strdup(inet_ntoa(dst4.sin_addr))) == NULL) - err(1, "malloc"); - } else - target = *argv; + target = *argv; memset(&hints, 0, sizeof(hints)); hints.ai_family = v6flag ? AF_INET6 : AF_INET; @@ -479,11 +474,6 @@ main(int argc, char *argv[]) freeaddrinfo(res); if (source) { - if (inet_aton(source, &from4.sin_addr) != 0) { - if ((source = strdup(inet_ntoa(from4.sin_addr))) == - NULL) - err(1, "malloc"); - } memset(&hints, 0, sizeof(hints)); hints.ai_family = dst->sa_family; if ((error = getaddrinfo(source, NULL, &hints, &res))) -- cgit v1.2.3