]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Fix an unaligned access on OpenBSD/sparc64
authorJérémie Courrèges-Anglas <jca@wxcvbn.org>
Sat, 10 Jun 2017 14:48:44 +0000 (16:48 +0200)
committerGert Doering <gert@greenie.muc.de>
Sun, 11 Jun 2017 10:07:06 +0000 (12:07 +0200)
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 <gert@greenie.muc.de>
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 <gert@greenie.muc.de>
(cherry picked from commit 3e4e300d6c5ea9c320e62def79e5b70f8e255248)

src/openvpn/tun.c

index 72ec35cddd1ede708046cb74ee5a54b3aba57031..536601bb15df4c92e27df44b574c3f1cd620b8ec 100644 (file)
@@ -1349,12 +1349,12 @@ 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 (tt->ipv6 && iph->ip_v == 6)
-            type = htonl (AF_INET6);
+        if (tt->ipv6 && OPENVPN_IPH_GET_VER(iph->version_len) == 6)
+            type = htonl(AF_INET6);
         else
             type = htonl (AF_INET);