Skip to content

Safer handling of unix socket address names#13

Merged
dallison merged 1 commit intodallison:mainfrom
mikael-s-persson:fix/safer_usocket_names
Sep 3, 2025
Merged

Safer handling of unix socket address names#13
dallison merged 1 commit intodallison:mainfrom
mikael-s-persson:fix/safer_usocket_names

Conversation

@mikael-s-persson
Copy link
Copy Markdown
Contributor

Safer handling of unix socket address names

I believe this is a safer way to handle the addr name/len fields.

For context, I had a very weird issue related to testing the most recent version of subspace where it looked like the bound_address_ field was getting clobbered (seg-faulting on tear-down due to memory corruption). It turns out, the error was some weird version-skew between two dependency paths to cpp-toolbelt due to Bazel's module handling, and it was actually slicing old and new versions of UnixSocket with and without that field. Anyhow, that led me to scrutinize anything in that code that might be suspicious. And thus, the following PR.

Mainly, the changes in sockets.cc are more pedantically making sure to respect the size of the sockaddr_un struct, both going in and coming out. I figured it can't hurt. I believe I did it the recommended way, although the posix docs are really confusing.

The changes in the header is just, again, being pedantic to make sure you can't accidentally slice the non-virtual base classes Socket and NetworkSocket. In tests, this just worked, it looks like at least subspace and coroutines libs don't wrongly use those base class directly.

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 this pull request may close these issues.

2 participants