diff options
author | Paul Fox <pgf@brightstareng.com> | 2005-07-19 20:37:15 +0000 |
---|---|---|
committer | Paul Fox <pgf@brightstareng.com> | 2005-07-19 20:37:15 +0000 |
commit | b270315b2138701cf101f55f675c9445e5c16ba9 (patch) | |
tree | 37e2f30871b1cc70a4ef7eb9289538d7c9e3d9d4 | |
parent | 90161c92139c03fdcc060e472a764af604d25858 (diff) | |
download | busybox-w32-b270315b2138701cf101f55f675c9445e5c16ba9.tar.gz busybox-w32-b270315b2138701cf101f55f675c9445e5c16ba9.tar.bz2 busybox-w32-b270315b2138701cf101f55f675c9445e5c16ba9.zip |
applying fix for:
0000045: traceroute causes an alignment trap due to unaligned buffer on arm
-rw-r--r-- | networking/traceroute.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/networking/traceroute.c b/networking/traceroute.c index 44ffdf07e..c691551cd 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c | |||
@@ -77,6 +77,7 @@ | |||
77 | 77 | ||
78 | 78 | ||
79 | #define MAXPACKET 65535 /* max ip packet size */ | 79 | #define MAXPACKET 65535 /* max ip packet size */ |
80 | #define MAXPACKET_ICMP 512 | ||
80 | #ifndef MAXHOSTNAMELEN | 81 | #ifndef MAXHOSTNAMELEN |
81 | #define MAXHOSTNAMELEN 64 | 82 | #define MAXHOSTNAMELEN 64 |
82 | #endif | 83 | #endif |
@@ -101,7 +102,6 @@ struct opacket { | |||
101 | 102 | ||
102 | #include "busybox.h" | 103 | #include "busybox.h" |
103 | 104 | ||
104 | static u_char packet[512]; /* last inbound (icmp) packet */ | ||
105 | static struct opacket *outpacket; /* last output (udp) packet */ | 105 | static struct opacket *outpacket; /* last output (udp) packet */ |
106 | 106 | ||
107 | static int s; /* receive (icmp) socket file descriptor */ | 107 | static int s; /* receive (icmp) socket file descriptor */ |
@@ -185,7 +185,7 @@ deltaT(struct timeval *t1p, struct timeval *t2p) | |||
185 | } | 185 | } |
186 | 186 | ||
187 | static inline int | 187 | static inline int |
188 | wait_for_reply(int sock, struct sockaddr_in *from, int reset_timer) | 188 | wait_for_reply(int sock, struct sockaddr_in *from, int reset_timer, u_char *packet, int size) |
189 | { | 189 | { |
190 | fd_set fds; | 190 | fd_set fds; |
191 | static struct timeval wait; | 191 | static struct timeval wait; |
@@ -212,7 +212,7 @@ wait_for_reply(int sock, struct sockaddr_in *from, int reset_timer) | |||
212 | } | 212 | } |
213 | 213 | ||
214 | if (select(sock+1, &fds, (fd_set *)0, (fd_set *)0, &wait) > 0) | 214 | if (select(sock+1, &fds, (fd_set *)0, (fd_set *)0, &wait) > 0) |
215 | cc=recvfrom(s, (char *)packet, sizeof(packet), 0, | 215 | cc=recvfrom(s, (char *)packet, size, 0, |
216 | (struct sockaddr *)from, &fromlen); | 216 | (struct sockaddr *)from, &fromlen); |
217 | 217 | ||
218 | return(cc); | 218 | return(cc); |
@@ -339,10 +339,12 @@ traceroute_main(int argc, char *argv[]) | |||
339 | struct hostent *hp; | 339 | struct hostent *hp; |
340 | struct sockaddr_in from, *to; | 340 | struct sockaddr_in from, *to; |
341 | int ch, i, on, probe, seq, tos, ttl; | 341 | int ch, i, on, probe, seq, tos, ttl; |
342 | u_char *packet; | ||
342 | 343 | ||
343 | int options = 0; /* socket options */ | 344 | int options = 0; /* socket options */ |
344 | char *source = 0; | 345 | char *source = 0; |
345 | int nprobes = 3; | 346 | int nprobes = 3; |
347 | packet = xmalloc (MAXPACKET_ICMP); | ||
346 | 348 | ||
347 | on = 1; | 349 | on = 1; |
348 | seq = tos = 0; | 350 | seq = tos = 0; |
@@ -494,7 +496,7 @@ traceroute_main(int argc, char *argv[]) | |||
494 | (void) gettimeofday(&t1, &tz); | 496 | (void) gettimeofday(&t1, &tz); |
495 | send_probe(++seq, ttl); | 497 | send_probe(++seq, ttl); |
496 | reset_timer = 1; | 498 | reset_timer = 1; |
497 | while ((cc = wait_for_reply(s, &from, reset_timer)) != 0) { | 499 | while ((cc = wait_for_reply(s, &from, reset_timer, packet, MAXPACKET_ICMP)) != 0) { |
498 | (void) gettimeofday(&t2, &tz); | 500 | (void) gettimeofday(&t2, &tz); |
499 | if ((i = packet_ok(packet, cc, &from, seq))) { | 501 | if ((i = packet_ok(packet, cc, &from, seq))) { |
500 | reset_timer = 1; | 502 | reset_timer = 1; |