Merged
Conversation
This is a simple end-to-end test for abstract sockets. It is possible to
implement tests for address bounds, but those require system specific
information and would require exports from `Network.Socket.Types`. As
such a simple end-to-end tests provides a good balance of coverage.
Simple bounds checking may look like:
```
it "can end-to-end with long abstract socket names" $ do
when isUnixDomainSocketAvailable $ do
let
abstractAddress =
toEnum 0:
"/haskell/network/long-abstract-" ++
replicate 76 'a'
clientAct sock = send sock testMsg
server (sock, addr) = do
recv sock 1024 `shouldReturn` testMsg
addr `shouldBe` (SockAddrUnix "")
unixTestWith abstractAddress (const $ pure ()) clientAct server
it "fails with too long abstract socket names" $ do
when isUnixDomainSocketAvailable $ do
let
abstractAddress =
toEnum 0:
"/haskell/network/long-abstract-" ++
replicate 77 'a'
clientAct _ = pure ()
server _ = pure ()
unixTestWith abstractAddress (const $ pure ()) clientAct server
`shouldThrow` anyErrorCall
```
However this hard codes the bounds and would fail when system specific
configuration differs.
There are two cases where pokeSockAddr can write past the end of the sockaddr_un structure and corrupt the heap: - when processing a very large Unix socket path - when processing the address of a Linux abstract Unix socket, where (2 + length path) bytes are allocated but sizeof(sockadr_un) are written. The fix is backported from version 3.0.0.0.
This was referenced Apr 23, 2019
Closed
eborden
approved these changes
Apr 24, 2019
Collaborator
eborden
left a comment
There was a problem hiding this comment.
Thanks for jumping on this!
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
accept(Unix domain #306) (the error is fixed)