Skip to content

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

@nh2

Description

@nh2

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions