aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorErik Andersen <andersen@codepoet.org>2000-01-29 05:52:40 +0000
committerErik Andersen <andersen@codepoet.org>2000-01-29 05:52:40 +0000
commit8e759aa31fa3f0dea6686cb7194398e68ff76696 (patch)
treebf85d9f769971c50e4c16ebeb4475a1e092c0fed /networking
parentd7a44c76fe22873893b995ab62ce4112fad99c66 (diff)
downloadbusybox-8e759aa31fa3f0dea6686cb7194398e68ff76696.tar.gz
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
Diffstat (limited to 'networking')
-rw-r--r--networking/ping.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/networking/ping.c b/networking/ping.c
index 2b6e7f5f2..5cadac3e8 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -1,5 +1,5 @@
/*
- * $Id: ping.c,v 1.7 2000/01/26 20:06:48 erik Exp $
+ * $Id: ping.c,v 1.8 2000/01/29 05:52:40 erik Exp $
* Mini ping implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@@ -312,18 +312,14 @@ static void unpack(char *buf, int sz, struct sockaddr_in *from)
static void ping(char *host)
{
- struct protoent *proto;
+ struct protoent *proto=NULL;
struct hostent *h;
char buf[MAXHOSTNAMELEN];
char packet[DEFDATALEN + MAXIPLEN + MAXICMPLEN];
int sockopt;
- if (!(proto = getprotobyname("icmp"))) {
- /* getprotobyname failed, so just silently force
- * proto->p_proto to have the correct value for "icmp" */
- proto->p_proto = 1;
- }
- if ((pingsock = socket(AF_INET, SOCK_RAW, proto->p_proto)) < 0) { /* 1 == ICMP */
+ proto = getprotobyname("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 {