@@ -188,10 +188,40 @@ version (linux)
188188
189189 extern (D ) inout (ubyte )* CMSG_DATA ( return scope inout (cmsghdr)* cmsg ) pure nothrow @nogc { return cast (ubyte * )( cmsg + 1 ); }
190190
191- private inout (cmsghdr)* __cmsg_nxthdr (inout (msghdr)* , inout (cmsghdr)* ) pure nothrow @nogc ;
192- extern (D ) inout (cmsghdr)* CMSG_NXTHDR (inout (msghdr)* msg, inout (cmsghdr)* cmsg) pure nothrow @nogc
191+ version (CRuntime_Musl )
193192 {
194- return __cmsg_nxthdr (msg, cmsg);
193+ extern (D )
194+ {
195+ private size_t __CMSG_LEN (inout (cmsghdr)* cmsg) pure nothrow @nogc
196+ {
197+ return (cmsg.cmsg_len + size_t .sizeof - 1 ) & cast (size_t )(~ (size_t .sizeof - 1 ));
198+ }
199+
200+ private inout (cmsghdr)* __CMSG_NEXT (inout (cmsghdr)* cmsg) pure nothrow @nogc
201+ {
202+ return cmsg + __CMSG_LEN(cmsg);
203+ }
204+
205+ private inout (msghdr)* __MHDR_END (inout (msghdr)* mhdr) pure nothrow @nogc
206+ {
207+ return cast (inout (msghdr)* )(mhdr.msg_control + mhdr.msg_controllen);
208+ }
209+
210+ inout (cmsghdr)* CMSG_NXTHDR (inout (msghdr)* msg, inout (cmsghdr)* cmsg) pure nothrow @nogc
211+ {
212+ return cmsg.cmsg_len < cmsghdr.sizeof ||
213+ __CMSG_LEN(cmsg) + cmsghdr.sizeof >= __MHDR_END(msg) - cast (inout (msghdr)* )(cmsg)
214+ ? cast (inout (cmsghdr)* ) null : cast (inout (cmsghdr)* ) __CMSG_NEXT(cmsg);
215+ }
216+ }
217+ }
218+ else
219+ {
220+ private inout (cmsghdr)* __cmsg_nxthdr (inout (msghdr)* , inout (cmsghdr)* ) pure nothrow @nogc ;
221+ extern (D ) inout (cmsghdr)* CMSG_NXTHDR (inout (msghdr)* msg, inout (cmsghdr)* cmsg) pure nothrow @nogc
222+ {
223+ return __cmsg_nxthdr (msg, cmsg);
224+ }
195225 }
196226
197227 extern (D ) inout (cmsghdr)* CMSG_FIRSTHDR ( inout (msghdr)* mhdr ) pure nothrow @nogc
0 commit comments