[Pkg-privacy-commits] [onioncat] 210/340: pointer dereferences recoded in respect to strict alias checking of compiler

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 13:04:41 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch debian
in repository onioncat.

commit 2ebeb1f13264a2aa9d89bd68a4d0337379c95047
Author: eagle <eagle at 58e1ccc2-750e-0410-8d0d-f93ca75ab447>
Date:   Fri Feb 5 10:59:17 2010 +0000

    pointer dereferences recoded in respect to strict alias checking of compiler
    
    git-svn-id: http://www.cypherpunk.at/svn/onioncat/trunk@539 58e1ccc2-750e-0410-8d0d-f93ca75ab447
---
 src/ocat.h      |  2 ++
 src/ocateth.c   |  7 ++++---
 src/ocatroute.c | 22 ++++++++++++++++++----
 3 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/src/ocat.h b/src/ocat.h
index 4038458..f5bbcb0 100644
--- a/src/ocat.h
+++ b/src/ocat.h
@@ -523,6 +523,8 @@ int run_listeners(struct sockaddr **, int *, int, int (*)(int));
 int send_keepalive(OcatPeer_t *);
 void set_select_timeout(struct timeval *);
 void set_nonblock(int);
+void set_tunheader(char *, uint32_t);
+uint32_t get_tunheader(char *);
 
 /* ocatthread.c */
 const OcatThread_t *init_ocat_thread(const char *);
diff --git a/src/ocateth.c b/src/ocateth.c
index 8198ec3..f6c76f3 100644
--- a/src/ocateth.c
+++ b/src/ocateth.c
@@ -249,10 +249,11 @@ int ndp_solicit(const struct in6_addr *src, const struct in6_addr *dst)
    memcpy(((char*) &mcastd) + 13, ((char*) dst) + 13, 3);
 
    // tunnel header
-   *((uint32_t*) buf) = htonl(CNF(fhd_key[IPV6_KEY]));
+   set_tunheader(buf, htonl(CNF(fhd_key[IPV6_KEY])));
 
    // ethernet header
-   *((uint16_t*) ndp6->eth.ether_dhost) = 0x3333;
+   ndp6->eth.ether_dhost[0] = 0x33;
+   ndp6->eth.ether_dhost[1] = 0x33;
    memcpy(&ndp6->eth.ether_dhost[2], ((char*) &mcastd) + 12, 4);
    memcpy(ndp6->eth.ether_shost, CNF(ocat_hwaddr), ETHER_ADDR_LEN);
    ndp6->eth.ether_type = htons(ETHERTYPE_IPV6);
@@ -448,7 +449,7 @@ int eth_check(char *buf, int len)
    }
 
    // check ethernet destination
-   if ((*((uint16_t*) &ndp6->eth.ether_dhost) != 0x3333) && memcmp(ndp6->eth.ether_dhost, CNF(ocat_hwaddr), ETHER_ADDR_LEN))
+   if ((ndp6->eth.ether_dhost[0] != 0x33) && (ndp6->eth.ether_dhost[1] != 0x33) && memcmp(ndp6->eth.ether_dhost, CNF(ocat_hwaddr), ETHER_ADDR_LEN))
    {
       log_debug("unknown destination MAC");
       return E_ETH_ILLDEST;
diff --git a/src/ocatroute.c b/src/ocatroute.c
index b58f02f..c347a82 100644
--- a/src/ocatroute.c
+++ b/src/ocatroute.c
@@ -264,6 +264,20 @@ void set_select_timeout(struct timeval *tv)
 }
 
 
+void set_tunheader(char *buf, uint32_t tunhdr)
+{
+   uint32_t *ibuf = (uint32_t*) buf;
+   *ibuf = tunhdr;
+}
+
+
+uint32_t get_tunheader(char *buf)
+{
+   uint32_t *ibuf = (uint32_t*) buf;
+   return *ibuf;
+}
+
+
 void *socket_receiver(void *p)
 {
    int maxfd, len;
@@ -511,7 +525,7 @@ void *socket_receiver(void *p)
                   }
                   else
                   {
-                     *((uint32_t*) buf) = *peer->tunhdr;
+                     set_tunheader(buf, *peer->tunhdr);
                      memcpy(buf + 4 + sizeof(struct ether_header), peer->fragbuf, len);
                      memcpy(eh->ether_shost, CNF(ocat_hwaddr), ETHER_ADDR_LEN);
 
@@ -863,7 +877,7 @@ void packet_forwarder(void)
          memmove(eh, eh + 1, rlen - 4);
       }
 
-      if (*((uint32_t*) buf) == CNF(fhd_key[IPV6_KEY]))
+      if (get_tunheader(buf) == CNF(fhd_key[IPV6_KEY]))
       {
          if (((rlen - 4) < IP6HLEN))
          {
@@ -882,7 +896,7 @@ void packet_forwarder(void)
          if (!(dest = ipv6_lookup_route(&((struct ip6_hdr*) &buf[4])->ip6_dst)))
             dest = &((struct ip6_hdr*) &buf[4])->ip6_dst;
       }
-      else if (*((uint32_t*) buf) == CNF(fhd_key[IPV4_KEY]))
+      else if (get_tunheader(buf) == CNF(fhd_key[IPV4_KEY]))
       {
          if (((rlen - 4) < IPHDLEN))
          {
@@ -903,7 +917,7 @@ void packet_forwarder(void)
       }
       else
       {
-         log_msg(LOG_ERR, "protocol 0x%08x not supported. dropping frame.", ntohl(*((uint32_t*) buf)));
+         log_msg(LOG_ERR, "protocol 0x%08x not supported. dropping frame.", ntohl(get_tunheader(buf)));
          continue;
       }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onioncat.git



More information about the Pkg-privacy-commits mailing list