ping6 segfault

Joerg Epping joerg.epping at googlemail.com
Fri Jan 25 08:48:57 UTC 2013


Hello,

on ARM9 machines ping6 still segfaults sometimes. I tracked this down
to the unpack6/inet_ntop function. I think it's memory alignment
again.
Below there is my patch to solve this issue (only tested on ARM9).

Best regards,
Joerg

--- busybox-1.20.2/networking/ping.c	2012-06-26 15:35:45.000000000 +0200
+++ busybox-1.20.2_patched/networking/ping.c	2013-01-25 09:25:12.000000000 +0100
@@ -629,11 +629,13 @@ static void unpack6(char *packet, int sz
 	if (icmppkt->icmp6_type == ICMP6_ECHO_REPLY) {
 		uint16_t recv_seq = ntohs(icmppkt->icmp6_seq);
 		uint32_t *tp = NULL;
+		struct in6_addr target;

 		if (sz >= sizeof(struct icmp6_hdr) + sizeof(uint32_t))
 			tp = (uint32_t *) &icmppkt->icmp6_data8[4];
+		memcpy(&target, &from->sin6_addr, sizeof(struct in6_addr));
 		unpack_tail(sz, tp,
-			inet_ntop(AF_INET6, &from->sin6_addr,
+			inet_ntop(AF_INET6, &target,
 					buf, sizeof(buf)),
 			recv_seq, hoplimit);
 	} else if (icmppkt->icmp6_type != ICMP6_ECHO_REQUEST) {


More information about the busybox mailing list