Skip to content
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

unix: support long unix paths on macos + bsds #2917

Closed
wants to merge 2 commits into from

Conversation

bnoordhuis
Copy link
Member

@stale stale bot added the stale label Aug 11, 2020
Comment on lines +45 to +48
union uv__sockaddr_un {
struct sockaddr sa;
struct uv__sockaddr_un_path up;
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is offsetof a legal constexpr for C89? I'm not sure the type-punning (via the union) is desirable either, as it's not legal C code, though we are intending to turn off TBAA.

I wonder if we should instead use the normal struct definition, then add a storage type with the extra padding:

Suggested change
union uv__sockaddr_un {
struct sockaddr sa;
struct uv__sockaddr_un_path up;
};
union uv__sockaddr_un_storage {
struct sockaddr_un sa;
#ifdef SOCK_MAXADDRLEN
/* macOS and the BSDs support paths > sizeof(su.sun_path).
* SOCK_MAXADDRLEN is, to the best of my knowledge, always 255.
* Minus the two byte header, that leaves 253 bytes for the path.
*/
char up[SOCK_MAXADDRLEN];
#else
char up[sizeof(struct sockaddr_un)];
#endif
};

elsewhere, then, instead of sizeof(s->up.path) then, it'd be either sizeof(s->sa.path) + sizeof(s-> up) - sizeof(s->sa) or equivalently sizeof(s->up) - offsetof(struct sockaddr_un, sun_path)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @vtjnash, missed your comment.

Is offsetof a legal constexpr for C89?

Yes, IMO (compiler builtin), and easy enough to fix if someone somewhere is using an archaic compiler.

I'm not sure the type-punning (via the union) is desirable either

I suspect that's an academic concern because the only aliasing is between struct sockaddr and char pad[]. Even if it's not theoretic, libuv is built with -fno-strict-aliasing now.

Your suggestion would work but it feels like it has a larger margin for error so I'd rather stick with my approach.

@stale stale bot removed the stale label Nov 5, 2020
@stale stale bot added the stale label Nov 26, 2020
@stale stale bot closed this Jun 2, 2021
@vtjnash vtjnash reopened this Jun 2, 2021
@stale stale bot removed the stale label Jun 2, 2021
@stale stale bot added the stale label Jun 26, 2021
@stale stale bot removed the stale label Apr 8, 2022
@libuv libuv deleted a comment from stale bot Apr 8, 2022
@libuv libuv deleted a comment from stale bot Apr 8, 2022
The BSDs let you pass path names longer than sizeof(s.sun_path), they
read past the end when socklen > sizeof(struct sockaddr_un) up to a
limit of at least 255 characters.

This commit refactors src/unix/pipe.c to make it easy to support long
paths. The actual support will be done in a follow-up commit.

Refs: libuv#2826
See the previous commit. This commit allows paths up to 253 bytes
instead of the current restriction of 104 bytes.

Fixes: libuv#2826
@stale stale bot added the stale label Jun 12, 2022
@libuv libuv deleted a comment from stale bot Jun 12, 2022
@stale stale bot removed the stale label Jun 12, 2022
@bnoordhuis
Copy link
Member Author

Not stale, waiting on feedback on #2917 (comment).

@stale
Copy link

stale bot commented Jul 31, 2022

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

@stale stale bot added the stale label Jul 31, 2022
@gengjiawen gengjiawen removed the stale label Aug 10, 2022
@stale
Copy link

stale bot commented Sep 21, 2022

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

@stale stale bot added the stale label Sep 21, 2022
@bnoordhuis
Copy link
Member Author

I don't use macos or any of the bsds anymore so I don't expect I'll be fixing this up anytime soon. Closing.

@bnoordhuis bnoordhuis closed this Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unix: support long path names in pipe.c
4 participants