Skip to content

Commit

Permalink
Zero memory of sockaddr_un if abstract socket
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellwrosen committed Aug 12, 2016
1 parent a82a401 commit 3a62be6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Network/Socket/Types.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3a62be6

Please sign in to comment.