Skip to content

pokeSockAddr check ignores multi-char Unicode bytes and forgets about NULL terminator #584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nh2 opened this issue Jul 10, 2024 · 0 comments · Fixed by #585
Closed

pokeSockAddr check ignores multi-char Unicode bytes and forgets about NULL terminator #584

nh2 opened this issue Jul 10, 2024 · 0 comments · Fixed by #585
Assignees

Comments

@nh2
Copy link
Member

nh2 commented Jul 10, 2024

pokeSockAddr p sa@(SockAddrUnix path) = do
when (length path > unixPathMax) $ error
$ "pokeSockAddr: path is too long in SockAddrUnix " <> show path
<> ", length " <> show (length path) <> ", unixPathMax " <> show unixPathMax

The check length path > unixPathMax seems wrong:

  • It should be >= because there needs to be a Byte available for the trailing \0.
  • The comparison is made on Unicode chars (String) instead of C chars (Bytes)

https://hackage.haskell.org/package/network-3.2.1.0/docs/Network-Socket.html#v:SockAddrUnix says

The path must have fewer than 104 characters. All of these characters must have code points less than 256.

but the check should enforce this properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants