File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -135,7 +135,7 @@ class UdpServerImpl : public UdpServer {
135135#if !defined(__linux__) && defined(IP_RECVIF)
136136 class ReadMessageControl {
137137 private:
138- alignas (cmsghdr) uint8_t m_data[sizeof (cmsghdr) + CMSG_SPACE(sizeof (sockaddr_dl))];
138+ alignas (cmsghdr) uint8_t m_data[CMSG_SPACE(sizeof (sockaddr_dl))];
139139 public:
140140 static constexpr size_t size () noexcept { return sizeof (m_data); }
141141 cmsghdr * data () noexcept { return reinterpret_cast <cmsghdr *>(m_data); }
@@ -149,10 +149,11 @@ class UdpServerImpl : public UdpServer {
149149 if (msg.msg_controllen < sizeof (struct cmsghdr ))
150150 return true ;
151151
152- for (struct cmsghdr * cmptr = CMSG_FIRSTHDR (&msg); cmptr; cmptr = CMSG_NXTHDR (&msg, cmptr)) {
152+ for (cmsghdr * cmptr = CMSG_FIRSTHDR (&msg); cmptr; cmptr = CMSG_NXTHDR (&msg, cmptr)) {
153153 if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_RECVIF) {
154- auto sdl = (struct sockaddr_dl *)CMSG_DATA (cmptr);
155- return sdl->sdl_index == ifIndex;
154+ sockaddr_dl sdl;
155+ memcpy (&sdl, CMSG_DATA (cmptr), sizeof (sdl));
156+ return sdl.sdl_index == ifIndex;
156157 }
157158 }
158159
You can’t perform that action at this time.
0 commit comments