From a6d0dbc86fd8a84f9c2a05f77013bd3eb5efa697 Mon Sep 17 00:00:00 2001 From: Erik Andersen Date: Sat, 29 Jan 2000 06:29:32 +0000 Subject: Minor change. init now uses dup2. -Erik --- networking/ping.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'networking') diff --git a/networking/ping.c b/networking/ping.c index 5cadac3e8..5b680195a 100644 --- a/networking/ping.c +++ b/networking/ping.c @@ -1,5 +1,5 @@ /* - * $Id: ping.c,v 1.8 2000/01/29 05:52:40 erik Exp $ + * $Id: ping.c,v 1.9 2000/01/29 06:29:32 erik Exp $ * Mini ping implementation for busybox * * Copyright (C) 1999 by Randolph Chung @@ -312,14 +312,17 @@ static void unpack(char *buf, int sz, struct sockaddr_in *from) static void ping(char *host) { - struct protoent *proto=NULL; + struct protoent *proto; struct hostent *h; char buf[MAXHOSTNAMELEN]; char packet[DEFDATALEN + MAXIPLEN + MAXICMPLEN]; int sockopt; proto = getprotobyname("icmp"); - if ((pingsock = socket(AF_INET, SOCK_RAW, (proto)? proto->p_proto : 1 )) < 0) { /* 1 == ICMP */ + /* if getprotobyname failed, just silently force + * proto->p_proto to have the correct value for "icmp" */ + if ((pingsock = socket(AF_INET, SOCK_RAW, + (proto ? proto->p_proto : 1))) < 0) { /* 1 == ICMP */ if (errno == EPERM) { fprintf(stderr, "ping: permission denied. (are you root?)\n"); } else { -- cgit v1.2.3