Safer handling of unix socket address names#13
Merged
dallison merged 1 commit intodallison:mainfrom Sep 3, 2025
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_unstruct, 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
SocketandNetworkSocket. In tests, this just worked, it looks like at least subspace and coroutines libs don't wrongly use those base class directly.