e43d961628
Aaron Stellman, revised by Daniel Dickman and myself. ok jasper@ ports is unlocked for a while only for those who have been informed. IF JASPER DID NOT MAIL YOU, DO NOT COMMIT!
84 lines
2.4 KiB
Plaintext
84 lines
2.4 KiB
Plaintext
$OpenBSD: patch-bing_c,v 1.3 2010/02/23 21:35:37 sthen Exp $
|
|
--- bing.c.orig Fri Jan 19 13:28:53 2001
|
|
+++ bing.c Thu Feb 18 12:35:25 2010
|
|
@@ -162,6 +162,7 @@ static char rcsid[] = "$Id: bing.c,v 1.16.2.1 2001/01/
|
|
|
|
#include <netinet/in_systm.h>
|
|
#include <netinet/in.h>
|
|
+#include <arpa/inet.h>
|
|
#include <netinet/ip.h>
|
|
#include <netinet/ip_icmp.h>
|
|
#ifndef linux
|
|
@@ -755,7 +756,7 @@ int pr_pack(buf, cc, from)
|
|
static int old_rrlen;
|
|
static char old_rr[MAX_IPOPTLEN];
|
|
struct ip *ip;
|
|
- struct timeval tv, *tp;
|
|
+ struct timeval tv, tv2, *tp;
|
|
double triptime;
|
|
int hlen, dupflag;
|
|
|
|
@@ -798,9 +799,12 @@ int pr_pack(buf, cc, from)
|
|
cc -= hlen;
|
|
icp = (struct icmp *)(buf + hlen);
|
|
if (icp->icmp_type == ICMP_ECHOREPLY) {
|
|
+ char *tmp;
|
|
if (icp->icmp_id != ident)
|
|
return -1; /* 'Twas not our ECHO */
|
|
- tp = (struct timeval *)ICMP_TO_DATA(icp);
|
|
+ tmp = (char *)ICMP_TO_DATA(icp);
|
|
+ memcpy(&tv2, tmp, sizeof(tv2));
|
|
+ tp = &tv2;
|
|
tvsub(&tv, tp);
|
|
triptime = tv_usval(&tv);
|
|
|
|
@@ -1231,17 +1235,30 @@ int main(argc, argv)
|
|
struct hoststats *hs1, *hs2;
|
|
int ntrans, nloops, bits;
|
|
int i;
|
|
- int ch, hold, recv_packlen, preload;
|
|
+ int ch, hold = 1, recv_packlen, preload;
|
|
u_char *datap, *recv_packet;
|
|
char *target1, *target2, *malloc();
|
|
u_char ttl, loop;
|
|
#ifdef IP_OPTIONS
|
|
char rspace[3 + 4 * NROUTES + 1]; /* record route space */
|
|
#endif
|
|
-
|
|
hs1 = &hoststats1;
|
|
hs2 = &hoststats2;
|
|
|
|
+ if (!(proto = getprotobyname("icmp"))) {
|
|
+ (void)fprintf(stderr, "bing: unknown protocol icmp.\n");
|
|
+ exit(1);
|
|
+ }
|
|
+ if ((s = socket(AF_INET, SOCK_RAW, proto->p_proto)) < 0) {
|
|
+ perror("bing: socket");
|
|
+ exit(1);
|
|
+ }
|
|
+ /* Revoke privileges */
|
|
+ if (seteuid(getuid()) == -1 || setuid(getuid()) == -1) {
|
|
+ err(1, "unable to drop permissions");
|
|
+ exit(1);
|
|
+ }
|
|
+
|
|
preload = 0;
|
|
datap = &outpack[8 + sizeof(struct timeval)];
|
|
while ((ch = getopt(argc, argv, "I:LRc:dDe:fh:i:l:nPp:rS:s:t:vVwz")) != EOF)
|
|
@@ -1398,15 +1415,6 @@ int main(argc, argv)
|
|
|
|
ident = getpid() & 0xFFFF;
|
|
|
|
- if (!(proto = getprotobyname("icmp"))) {
|
|
- (void)fprintf(stderr, "bing: unknown protocol icmp.\n");
|
|
- exit(1);
|
|
- }
|
|
- if ((s = socket(AF_INET, SOCK_RAW, proto->p_proto)) < 0) {
|
|
- perror("bing: socket");
|
|
- exit(1);
|
|
- }
|
|
- hold = 1;
|
|
if (options & F_SO_DEBUG)
|
|
(void)setsockopt(s, SOL_SOCKET, SO_DEBUG, (char *)&hold,
|
|
sizeof(hold));
|