Skip to content

std: replace the FromInner implementation for addresses with private conversion functions#136699

Merged
bors merged 1 commit into
rust-lang:masterfrom
joboet:netaddr_from_inner
Feb 13, 2025
Merged

std: replace the FromInner implementation for addresses with private conversion functions#136699
bors merged 1 commit into
rust-lang:masterfrom
joboet:netaddr_from_inner

Conversation

@joboet

@joboet joboet commented Feb 7, 2025

Copy link
Copy Markdown
Member

Having these implementation available crate-wide means that platforms not using sockets for their networking code have to stub out the libc definitions required to support them. This PR moves the conversions to private helper functions that are only available where actually needed.

I also fixed the signature of the function converting from a C socket address to a Rust one: taking a reference to a sockaddr_storage resulted in unsound usage inside LookupHost::next, which could create a reference to a structure smaller than sockaddr_storage. Thus I've replaced the argument type with a pointer and made the function unsafe.

@rustbot

rustbot commented Feb 7, 2025

Copy link
Copy Markdown
Collaborator

r? @cuviper

rustbot has assigned @cuviper.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added O-solid Operating System: SOLID S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 7, 2025
@cuviper

cuviper commented Feb 10, 2025

Copy link
Copy Markdown
Member

LGTM!

@bors r+

@bors

bors commented Feb 10, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit 68ff0f1 has been approved by cuviper

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 10, 2025
@workingjubilee

Copy link
Copy Markdown
Member

@bors r-

I think this failed here? UEFI #136887 (comment)

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 12, 2025
…e conversion functions

Having these implementation available crate-wide means that platforms not using sockets for their networking code have to stub out the libc definitions required to support them. This PR moves the conversions to private helper functions that are only available where actually needed.

I also fixed the signature of the function converting from a C socket address to a Rust one: taking a reference to a `sockaddr_storage` resulted in unsound usage inside  `LookupHost::next`, which could create a reference to a structure smaller than `sockaddr_storage`. Thus I've replaced the argument type with a pointer and made the function `unsafe`.
@joboet joboet force-pushed the netaddr_from_inner branch from 68ff0f1 to 80c60fe Compare February 12, 2025 13:14
@joboet

joboet commented Feb 12, 2025

Copy link
Copy Markdown
Member Author

I've rebased this to include #136615 and removed the stub C definitions there as well.
@bors r=@cuviper

@bors

bors commented Feb 12, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit 80c60fe has been approved by cuviper

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 12, 2025
@bors bors merged commit 4ce473c into rust-lang:master Feb 13, 2025
@rustbot rustbot added this to the 1.86.0 milestone Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-solid Operating System: SOLID S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants