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

Unsoundness in UnixPath #1494

Closed
coolreader18 opened this issue Aug 20, 2021 · 3 comments · Fixed by #1496
Closed

Unsoundness in UnixPath #1494

coolreader18 opened this issue Aug 20, 2021 · 3 comments · Fixed by #1496
Labels

Comments

@coolreader18
Copy link
Contributor

println!("{}", UnixAddr(sockaddr_un { sun_family: AF_UNIX as _, sun_path: [0; 108] }, 10000));

Output;

"@<\u{0} x 108><9892 bytes of garbage>"

Also in the PartialEq and Hash impls and as_abstract; anywhere that uses sun_path() raw without doing what path() does and calling strnlen (and even path() is stiill unsound, it still calls sun_path() and creates a slice with a length longer than it should have)

@coolreader18
Copy link
Contributor Author

I think it'd be best to just not have the fields be public; there's also a thing where because strnlen isn't called on creation of a UnixPath, two "different" paths can be != just because one's length is 1 greater than the other and includes the trailing nul.

@asomers asomers added the A-bug label Aug 21, 2021
@asomers
Copy link
Member

asomers commented Aug 21, 2021

Yep, I agree. The fields should never have been public. Are you planning to submit a PR to fix it?

@coolreader18
Copy link
Contributor Author

Sure, I can take a stab at it.

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 a pull request may close this issue.

2 participants