summaryrefslogtreecommitdiffstats
path: root/src/send.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-11-29 05:33:12 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-11-29 05:35:49 +0100
commit61349d3d273aa23935b0c413c5885005db2669db (patch)
tree9cbc05acb31476d45b48d4a51e9edca19328b8e8 /src/send.c
parentc13fe36e4c0730037ae75d51f7f052d916486aac (diff)
downloadfastd-61349d3d273aa23935b0c413c5885005db2669db.tar
fastd-61349d3d273aa23935b0c413c5885005db2669db.zip
Compile with -std=c99 and restructure some code to ensure there is no invalid aliasing (hopefully)
Diffstat (limited to 'src/send.c')
-rw-r--r--src/send.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/send.c b/src/send.c
index caaa9f6..9f76d31 100644
--- a/src/send.c
+++ b/src/send.c
@@ -42,8 +42,9 @@ static inline void add_pktinfo(struct msghdr *msg, const fastd_peer_address_t *l
msg->msg_controllen += cmsg->cmsg_len;
- struct in_pktinfo *pktinfo = (struct in_pktinfo*)CMSG_DATA(cmsg);
- pktinfo->ipi_spec_dst = local_addr->in.sin_addr;
+ struct in_pktinfo pktinfo = {};
+ pktinfo.ipi_spec_dst = local_addr->in.sin_addr;
+ memcpy(CMSG_DATA(cmsg), &pktinfo, sizeof(pktinfo));
return;
}
#endif
@@ -55,11 +56,13 @@ static inline void add_pktinfo(struct msghdr *msg, const fastd_peer_address_t *l
msg->msg_controllen += cmsg->cmsg_len;
- struct in6_pktinfo *pktinfo = (struct in6_pktinfo*)CMSG_DATA(cmsg);
- pktinfo->ipi6_addr = local_addr->in6.sin6_addr;
+ struct in6_pktinfo pktinfo = {};
+ pktinfo.ipi6_addr = local_addr->in6.sin6_addr;
if (IN6_IS_ADDR_LINKLOCAL(&local_addr->in6.sin6_addr))
- pktinfo->ipi6_ifindex = local_addr->in6.sin6_scope_id;
+ pktinfo.ipi6_ifindex = local_addr->in6.sin6_scope_id;
+
+ memcpy(CMSG_DATA(cmsg), &pktinfo, sizeof(pktinfo));
}
}