summaryrefslogtreecommitdiffstats
path: root/src/send.c
diff options
context:
space:
mode:
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));
}
}