File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -1156,15 +1156,16 @@ unixPathMax = #const sizeof(((struct sockaddr_un *)NULL)->sun_path)
1156
1156
-- | Write the given 'SockAddr' to the given memory location.
1157
1157
pokeSockAddr :: Ptr a -> SockAddr -> IO ()
1158
1158
pokeSockAddr p sa@ (SockAddrUnix path) = do
1159
- when (length path > unixPathMax) $ error
1159
+ let pathC = map castCharToCChar path
1160
+ len = length pathC
1161
+ when (len >= unixPathMax) $ error
1160
1162
$ " pokeSockAddr: path is too long in SockAddrUnix " <> show path
1161
- <> " , length " <> show ( length path) <> " , unixPathMax " <> show unixPathMax
1163
+ <> " , length " <> show len <> " , unixPathMax " <> show unixPathMax
1162
1164
zeroMemory p $ fromIntegral $ sizeOfSockAddr sa
1163
1165
# if defined(HAVE_STRUCT_SOCKADDR_SA_LEN)
1164
1166
(# poke struct sockaddr_un, sun_len) p ((# const sizeof(struct sockaddr_un)) :: Word8 )
1165
1167
# endif
1166
1168
(# poke struct sockaddr_un, sun_family) p ((# const AF_UNIX ) :: CSaFamily )
1167
- let pathC = map castCharToCChar path
1168
1169
-- the buffer is already filled with nulls.
1169
1170
pokeArray ((# ptr struct sockaddr_un, sun_path) p) pathC
1170
1171
pokeSockAddr p (SockAddrInet port addr) = do
You can’t perform that action at this time.
0 commit comments