-
Notifications
You must be signed in to change notification settings - Fork 197
Panic on Unix-domain sockets with length 108 #1316
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
Comments
The best way to fix this probably involves allowing It seems like |
Unix-domain socket address can be long enough that the NUL terminator does not fit. Handle this case by making `path()` return a `Cow<CStr>` and adding a NUL terminator as needed. Also add a `path_bytes()` function for returning the raw bytes. Fixes #1316.
Thanks for pointing out that this should be fixed for 1.0. I've now filed #1371 as a fix. A complication with |
* Handle non-NUL-terminated strings in `SocketAddrUnix`. Unix-domain socket address can be long enough that the NUL terminator does not fit. Handle this case by making `path()` return a `Cow<CStr>` and adding a NUL terminator as needed. Also add a `path_bytes()` function for returning the raw bytes. Fixes #1316. * Allocated `SocketAddrUnix::path()` with correct length (#1372) Using `.to_owned()` + `.push()` will cause a reallocation, because the initially allocated array with be one byte too short. We can use `CString::from_vec_with_nul_unchecked()` because it is a known invariant that the input does not contain any `NUL`s, not even the terminating `NUL`. --------- Co-authored-by: René Kijewski <[email protected]>
On Linux, Unix-domain sockets with a path of length 108 don't get a terminator within
sun_path
:https://man7.org/linux/man-pages/man7/unix.7.html#BUGS
Rustix currently panics on such paths:
#1004 (comment)
The text was updated successfully, but these errors were encountered: