Skip to content

bindUnix loses the last character on OpenBSD #23956

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
Zectbumo opened this issue Aug 14, 2024 · 1 comment
Closed

bindUnix loses the last character on OpenBSD #23956

Zectbumo opened this issue Aug 14, 2024 · 1 comment

Comments

@Zectbumo
Copy link
Contributor

Zectbumo commented Aug 14, 2024

Description

This will create a socket file named "hell"

import std/net
let sock = newSocket(AF_UNIX, SOCK_STREAM, IPPROTO_IP)
sock.bindUnix("hello")

Nim Version

Nim Compiler Version 1.6.18 [OpenBSD: amd64]
Compiled at 2024-03-17
Copyright (c) 2006-2023 by Andreas Rumpf

active boot switches: -d:release

Current Output

$ ls h*
hell

Expected Output

$ ls h*
hello

Possible Solution

I'm guessing there is some issue with null terminated strings. Linux man pages mentions a historical issue here:

In addition, some implementations don't require a null terminator
when binding a socket (the addrlen argument is used to determine
the length of sun_path) and when the socket address is retrieved
on these implementations, there is no null terminator in
sun_path.

https://man7.org/linux/man-pages/man7/unix.7.html

Additional Information

Works fine in Ubuntu 22.04 / Nim 1.6.14
Broken in amd64 OpenBSD 7.3 / Nim 1.6.6
Broken in amd64 OpenBSD 7.4 / Nim 1.6.14
Broken in amd64 OpenBSD 7.5 / Nim 1.6.18
Broken in amd64 OpenBSD 7.5 / Nim 2.0.8

@Zectbumo
Copy link
Contributor Author

Zectbumo commented Aug 15, 2024

Pull request to fix this #23961

Zectbumo added a commit to Zectbumo/Nim that referenced this issue Aug 20, 2024
@Araq Araq closed this as completed in cb7bcae Aug 22, 2024
Zectbumo added a commit to Zectbumo/Nim that referenced this issue Apr 24, 2025
Zectbumo added a commit to Zectbumo/Nim that referenced this issue Apr 24, 2025
Zectbumo added a commit to Zectbumo/Nim that referenced this issue Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants