diff --git a/src/openvpn/clinat.c b/src/openvpn/clinat.c
index fc4acef..a046324 100644
--- a/src/openvpn/clinat.c
+++ b/src/openvpn/clinat.c
@@ -247,32 +247,45 @@
 
         ADJUST_CHECKSUM(accumulate, h->ip.check);
 
+        /* The TCP/UDP header follows any IP options, and only the first
+         * fragment carries it. */
+        const int hlen = OPENVPN_IPH_GET_LEN(h->ip.version_len);
+        struct buffer l4 = *ipbuf;
+        if ((ntohs(h->ip.frag_off) & OPENVPN_IP_OFFMASK) || hlen < (int)sizeof(struct openvpn_iphdr)
+            || !buf_advance(&l4, hlen))
+        {
+            return;
+        }
+
         if (h->ip.protocol == OPENVPN_IPPROTO_TCP)
         {
-            if (BLENZ(ipbuf) >= sizeof(struct openvpn_iphdr) + sizeof(struct openvpn_tcphdr))
+            if (BLENZ(&l4) >= sizeof(struct openvpn_tcphdr))
             {
-                ADJUST_CHECKSUM(accumulate, h->u.tcp.check);
+                struct openvpn_tcphdr *tcp = (struct openvpn_tcphdr *)BPTR(&l4);
+                ADJUST_CHECKSUM(accumulate, tcp->check);
             }
         }
         else if (h->ip.protocol == OPENVPN_IPPROTO_UDP)
         {
-            if (BLENZ(ipbuf) >= sizeof(struct openvpn_iphdr) + sizeof(struct openvpn_udphdr))
+            if (BLENZ(&l4) >= sizeof(struct openvpn_udphdr))
             {
+                struct openvpn_udphdr *udp = (struct openvpn_udphdr *)BPTR(&l4);
+
                 /* RFC 768: a UDP checksum of 0 means "no checksum computed".
                  * Do not run the incremental adjustment over a non-checksum,
                  * or we will write a bogus non-zero value into the field.
                  */
-                if (h->u.udp.check)
+                if (udp->check)
                 {
-                    ADJUST_CHECKSUM(accumulate, h->u.udp.check);
+                    ADJUST_CHECKSUM(accumulate, udp->check);
 
-                    if (!h->u.udp.check)
+                    if (!udp->check)
                     {
                         /* RFC 768: a computed checksum of 0 must be transmitted
                          * as 0xFFFF (one-complement), because 0 is reserved for
                          * "no checksum computed"
                          */
-                        h->u.udp.check = 0xFFFF;
+                        udp->check = 0xFFFF;
                     }
                 }
             }
