]> git.saurik.com Git - apple/ipsec.git/blobdiff - ipsec-tools/racoon/isakmp_frag.c
ipsec-164.9.tar.gz
[apple/ipsec.git] / ipsec-tools / racoon / isakmp_frag.c
index 304e825d2d30b163fc01e53fbdc82906d8351161..a42ab4e62007f78045f7b3ba5971d819db5534ce 100644 (file)
@@ -82,6 +82,7 @@
 #include "nattraversal.h"
 #include "grabmyaddr.h"
 #include "localconf.h"
+#include "crypto_openssl.h"
 
 int
 isakmp_sendfrags(iph1, buf) 
@@ -96,7 +97,6 @@ isakmp_sendfrags(iph1, buf)
        size_t max_datalen;
        size_t fraglen;
        vchar_t *frag;
-       unsigned int trailer;
        unsigned int fragnum = 0;
        size_t len;
        int etype;
@@ -110,7 +110,7 @@ isakmp_sendfrags(iph1, buf)
 
 
        /* select the socket to be sent */
-       s = getsockmyaddr(iph1->local);
+       s = getsockmyaddr((struct sockaddr *)iph1->local);
        if (s == -1){
                return -1;
        }
@@ -176,7 +176,7 @@ isakmp_sendfrags(iph1, buf)
                                vfree(frag);
                                return -1;
                        }
-                       *(u_int32_t *)vbuf->v = 0; // non-esp marker
+                       *ALIGNED_CAST(u_int32_t *)vbuf->v = 0; // non-esp marker
                        memcpy(vbuf->v + extralen, frag->v, frag->l);
                        vfree(frag);
                        frag = vbuf;
@@ -209,7 +209,7 @@ vendorid_frag_cap(gen)
        int *hp;
        int hashlen_bytes = eay_md5_hashlen() >> 3;
 
-       hp = (int *)(gen + 1);
+       hp = ALIGNED_CAST(int *)(gen + 1);
 
        return ntohl(hp[hashlen_bytes / sizeof(*hp)]);
 }
@@ -223,7 +223,6 @@ isakmp_frag_extract(iph1, msg)
        struct isakmp_frag *frag;
        struct isakmp_frag_item *item;
        vchar_t *buf;
-       size_t len;
        int last_frag = 0;
        char *data;
        int i;
@@ -408,7 +407,7 @@ isakmp_frag_addcap(buf, cap)
        vchar_t *buf;
        int cap;
 {
-       int *capp;
+       int val, *capp;
        size_t len;
        int hashlen_bytes = eay_md5_hashlen() >> 3;
 
@@ -420,13 +419,14 @@ isakmp_frag_addcap(buf, cap)
                            "Cannot allocate memory\n");
                        return NULL;
                }
-               capp = (int *)(buf->v + len);
-               *capp = htonl(0);
-       }
-
-       capp = (int *)(buf->v + hashlen_bytes);
-       *capp |= htonl(cap);
-
+        val = 0;                                    
+        memcpy(buf->v + len, &val, sizeof(val));        // Wcast_lign fix - copy instead of assign for unaligned move
+    }
+    capp = (int *)(void*)(buf->v + hashlen_bytes);      // Wcast_lign fix - copy instead of assign for unaligned move
+    memcpy(&val, capp, sizeof(val));
+    val |= htonl(cap);
+    memcpy(capp, &val, sizeof(val));
+           
        return buf;
 }
 
@@ -434,8 +434,8 @@ int
 sendfragsfromto(s, buf, local, remote, count_persend, frag_flags) 
        int              s;
        vchar_t         *buf;
-       struct sockaddr *local;
-       struct sockaddr *remote;
+       struct sockaddr_storage *local;
+       struct sockaddr_storage *remote;
        int              count_persend;
        u_int32_t        frag_flags;
 {
@@ -448,7 +448,6 @@ sendfragsfromto(s, buf, local, remote, count_persend, frag_flags)
        size_t max_datalen;
        size_t fraglen;
        vchar_t *frag;
-       unsigned int trailer;
        unsigned int fragnum = 0;
        size_t len;
 #ifdef ENABLE_NATT
@@ -519,7 +518,7 @@ sendfragsfromto(s, buf, local, remote, count_persend, frag_flags)
                                vfree(frag);
                                return -1;
                        }
-                       *(u_int32_t *)vbuf->v = 0; // non-esp marker
+                       *ALIGNED_CAST(u_int32_t *)vbuf->v = 0; // non-esp marker
                        memcpy(vbuf->v + extralen, frag->v, frag->l);
                        vfree(frag);
                        frag = vbuf;