From 3a62be6024b0e40b49c8d379043c25f3802cb0cc Mon Sep 17 00:00:00 2001 From: Mitchell Rosen Date: Fri, 12 Aug 2016 00:17:02 -0400 Subject: [PATCH] Zero memory of sockaddr_un if abstract socket --- Network/Socket/Types.hsc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Network/Socket/Types.hsc b/Network/Socket/Types.hsc index b42c98d0..553139a1 100644 --- a/Network/Socket/Types.hsc +++ b/Network/Socket/Types.hsc @@ -922,6 +922,10 @@ pokeSockAddr :: Ptr a -> SockAddr -> IO () pokeSockAddr p (SockAddrUnix path) = do #if defined(darwin_HOST_OS) zeroMemory p (#const sizeof(struct sockaddr_un)) +#else + case path of + ('\0':_) -> zeroMemory p (#const sizeof(struct sockaddr_un)) + _ -> pure () #endif #if defined(HAVE_STRUCT_SOCKADDR_SA_LEN) (#poke struct sockaddr_un, sun_len) p ((#const sizeof(struct sockaddr_un)) :: Word8)