SIGBUS on SPARCv9

Elrond
2003-10-03T12:24:49Z

Hi there,

I run tinc with not ConnectTo, (and it can't tcp-connect to
the relevant other tincd, because that tincd is behind a
firewall --> that tincd usualy connects to my tincd).

If I start that tincd alone (not connected at all) and do a
ping some_other_ip, it gets a SIGBUS in route.c:207 in the
function route_ipv4_unreachable at the line:
        hdr->ip_v = 4;

This seems to be an alignment problem.

I've appended a quick fix for this, which at least makes
tinc not crash any more.


    Elrond
-------------- next part --------------
--- route.c~	Thu Jul 31 15:18:34 2003
+++ route.c	Fri Oct  3 12:04:54 2003
@@ -174,7 +174,9 @@

 static void route_ipv4_unreachable(vpn_packet_t *packet, uint8_t code)
 {
-	struct ip *hdr;
+	struct ip local_hdr;
+	struct ip *hdr = &local_hdr;
+	struct ip *phdr;
 	struct icmp *icmp;

 	struct in_addr ip_src;
@@ -186,7 +188,7 @@

 	cp();

-	hdr = (struct ip *)(packet->data + 14);
+	phdr = (struct ip *)(packet->data + 14);
 	icmp = (struct icmp *)(packet->data + 14 + 20);

 	/* Remember original source and destination */
@@ -217,7 +219,9 @@
 	memcpy(&hdr->ip_dst, &ip_src, 4);

 	hdr->ip_sum = inet_checksum(hdr, 20, ~0);
-
+
+	memcpy(phdr, hdr, sizeof(*phdr));
+
 	/* Fill in ICMP header */

 	icmp->icmp_type = ICMP_DEST_UNREACH;