-
Notifications
You must be signed in to change notification settings - Fork 21
fix(toolbox): Correctly print unix sockets with no path #310
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,11 +70,17 @@ template <typename StreamT, typename T> | |
| StreamT& print_unix_endpoint(StreamT& os, const T& ep) | ||
| { | ||
| constexpr const char* scheme = "unix://"; | ||
| // abstract unix socket's path starts with '\0' and not null-terminated | ||
| const size_t family_size = sizeof(std::declval<sockaddr_un>().sun_family); | ||
| if (ep.size() <= family_size) { | ||
| // No path | ||
| os << scheme; | ||
| return os; | ||
| } | ||
| const auto* path = reinterpret_cast<const sockaddr_un*>(ep.data())->sun_path; | ||
| if (path[0] == '\0') { | ||
ItsLifeJim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| size_t size = ep.size() - sizeof(std::declval<sockaddr_un>().sun_family) - 1; | ||
| os << scheme << '|' << std::string_view{path + 1, size}; | ||
| // abstract unix socket's path starts with '\0' and not null-terminated | ||
| const size_t path_size = ep.size() - family_size; | ||
ItsLifeJim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| os << scheme << '|' << std::string_view{path + 1, path_size - 1}; | ||
| return os; | ||
| } | ||
| os << scheme << *ep.data(); | ||
ItsLifeJim marked this conversation as resolved.
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'm not sure null terminator is guaranteed for non-abstract unix sockets -- in which case this could print a very large sequence of bytes. I think this should be bounded by
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm actually i don't even know what
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, so it actually invokes this function at bottom, which then calls first function:
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.