aboutsummaryrefslogtreecommitdiff
path: root/ping.c
diff options
context:
space:
mode:
authorerik <erik@69ca8d6d-28ef-0310-b511-8ec308f3f277>2000-01-29 05:52:40 +0000
committererik <erik@69ca8d6d-28ef-0310-b511-8ec308f3f277>2000-01-29 05:52:40 +0000
commit78b8594add37cb36dabc7b78fb071a3621707117 (patch)
treebf85d9f769971c50e4c16ebeb4475a1e092c0fed /ping.c
parentf944869377f715439b35080cf68137457a964714 (diff)
downloadbusybox-w32-78b8594add37cb36dabc7b78fb071a3621707117.tar.gz
busybox-w32-78b8594add37cb36dabc7b78fb071a3621707117.tar.bz2
busybox-w32-78b8594add37cb36dabc7b78fb071a3621707117.zip
copy fixes to simplify link copying and always do the right thing.
ping could segfault because I'm an idiot, and tried to put a value in where I hadn't allocated storage. choke. -Erik git-svn-id: svn://busybox.net/trunk/busybox@346 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'ping.c')
-rw-r--r--ping.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/ping.c b/ping.c
index 2b6e7f5f2..5cadac3e8 100644
--- a/ping.c
+++ b/ping.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: ping.c,v 1.7 2000/01/26 20:06:48 erik Exp $ 2 * $Id: ping.c,v 1.8 2000/01/29 05:52:40 erik Exp $
3 * Mini ping implementation for busybox 3 * Mini ping implementation for busybox
4 * 4 *
5 * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> 5 * Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@@ -312,18 +312,14 @@ static void unpack(char *buf, int sz, struct sockaddr_in *from)
312 312
313static void ping(char *host) 313static void ping(char *host)
314{ 314{
315 struct protoent *proto; 315 struct protoent *proto=NULL;
316 struct hostent *h; 316 struct hostent *h;
317 char buf[MAXHOSTNAMELEN]; 317 char buf[MAXHOSTNAMELEN];
318 char packet[DEFDATALEN + MAXIPLEN + MAXICMPLEN]; 318 char packet[DEFDATALEN + MAXIPLEN + MAXICMPLEN];
319 int sockopt; 319 int sockopt;
320 320
321 if (!(proto = getprotobyname("icmp"))) { 321 proto = getprotobyname("icmp");
322 /* getprotobyname failed, so just silently force 322 if ((pingsock = socket(AF_INET, SOCK_RAW, (proto)? proto->p_proto : 1 )) < 0) { /* 1 == ICMP */
323 * proto->p_proto to have the correct value for "icmp" */
324 proto->p_proto = 1;
325 }
326 if ((pingsock = socket(AF_INET, SOCK_RAW, proto->p_proto)) < 0) { /* 1 == ICMP */
327 if (errno == EPERM) { 323 if (errno == EPERM) {
328 fprintf(stderr, "ping: permission denied. (are you root?)\n"); 324 fprintf(stderr, "ping: permission denied. (are you root?)\n");
329 } else { 325 } else {