From 3e4e300d6c5ea9c320e62def79e5b70f8e255248 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Courr=C3=A8ges-Anglas?= Date: Sat, 10 Jun 2017 16:48:44 +0200 Subject: [PATCH] Fix an unaligned access on OpenBSD/sparc64 The pointer to the packet content doesn't seem to be word-aligned, resulting in a SIGBUS when accessing it as a pointer to struct ip that contains bit fields. Replace with struct openvpn_iphdr and OPENVPN_IPH_GET_VER, which only does a one byte access and thus isn't affected by alignement. Acked-by: Gert Doering Message-Id: <87ink3vpcs.fsf@ritchie.wxcvbn.org> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg14769.html Signed-off-by: Gert Doering --- src/openvpn/tun.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 3504fbf46..0ca0c19ed 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -1654,11 +1654,11 @@ write_tun_header(struct tuntap *tt, uint8_t *buf, int len) { u_int32_t type; struct iovec iv[2]; - struct ip *iph; + struct openvpn_iphdr *iph; - iph = (struct ip *) buf; + iph = (struct openvpn_iphdr *) buf; - if (iph->ip_v == 6) + if (OPENVPN_IPH_GET_VER(iph->version_len) == 6) { type = htonl(AF_INET6); } -- 2.47.2