Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/net/icmp Fix alignment of sndbuf (sparc64 got a SIGBUS...



details:   https://anonhg.NetBSD.org/src/rev/1b93075f6f8b
branches:  trunk
changeset: 760453:1b93075f6f8b
user:      martin <martin%NetBSD.org@localhost>
date:      Wed Jan 05 14:08:12 2011 +0000

description:
Fix alignment of sndbuf (sparc64 got a SIGBUS in this test)

diffstat:

 tests/net/icmp/t_ping.c |  11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diffs (39 lines):

diff -r 56dd061be064 -r 1b93075f6f8b tests/net/icmp/t_ping.c
--- a/tests/net/icmp/t_ping.c   Wed Jan 05 14:03:08 2011 +0000
+++ b/tests/net/icmp/t_ping.c   Wed Jan 05 14:08:12 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_ping.c,v 1.11 2010/11/07 17:51:21 jmmv Exp $ */
+/*     $NetBSD: t_ping.c,v 1.12 2011/01/05 14:08:12 martin Exp $       */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: t_ping.c,v 1.11 2010/11/07 17:51:21 jmmv Exp $");
+__RCSID("$NetBSD: t_ping.c,v 1.12 2011/01/05 14:08:12 martin Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -129,7 +129,10 @@
 static int
 doping(const char *target, int loops, u_int pktsize)
 {
-       char sndbuf[IP_MAXPACKET - sizeof(struct ip)];
+       union {
+               char buf[IP_MAXPACKET - sizeof(struct ip)];
+               struct icmp i;  /* ensure proper alignment */
+       } sndbuf;
        char recvbuf[IP_MAXPACKET];
        struct sockaddr_in dst, pingee;
        struct icmp *icmp;
@@ -147,7 +150,7 @@
        dst.sin_family = AF_INET;
        dst.sin_addr.s_addr = inet_addr(target);
 
-       icmp = (struct icmp *)sndbuf;
+       icmp = (struct icmp *)&sndbuf;
        memset(icmp, 0, sizeof(*icmp));
        icmp->icmp_type = ICMP_ECHO;
        icmp->icmp_id = htons(37);



Home | Main Index | Thread Index | Old Index