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

Panic if PathBuf::set_extension would add a path separator #125070

Merged
merged 1 commit into from
May 26, 2024

Conversation

tbu-
Copy link
Contributor

@tbu- tbu- commented May 13, 2024

This is likely never intended and potentially a security vulnerability if it happens.

I'd guess that it's mostly literal strings that are passed to this function in practice, so I'm guessing this doesn't break anyone.

CC #125060

@rustbot
Copy link
Collaborator

rustbot commented May 13, 2024

r? @jhpratt

rustbot has assigned @jhpratt.
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 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 May 13, 2024
@rust-log-analyzer

This comment has been minimized.

This is likely never intended and potentially a security vulnerability
if it happens.

I'd guess that it's mostly literal strings that are passed to this
function in practice, so I'm guessing this doesn't break anyone.

CC rust-lang#125060
@@ -1803,6 +1803,29 @@ fn test_windows_absolute() {
assert_eq!(absolute(r"COM1").unwrap().as_os_str(), Path::new(r"\\.\COM1").as_os_str());
}

#[test]
#[should_panic = "path separator"]
Copy link

Choose a reason for hiding this comment

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

Would test a try_set method be better than testing a panic one?

@jhpratt
Copy link
Member

jhpratt commented May 14, 2024

imo this needs a decision from T-libs (or T-libs-api? not sure). I personally find this reasonable, but it's not a trivial thing to change.

cc @rust-lang/libs

@workingjubilee workingjubilee added the I-libs-nominated The issue / PR has been nominated for discussion during a libs team meeting. label May 14, 2024
@workingjubilee
Copy link
Contributor

this and #125060 should probably be discussed together

@ChrisDenton
Copy link
Contributor

I think this (and the other one) are an API issue. This isn't just about the implementation. This is about the public API of Path.

@workingjubilee workingjubilee added the I-libs-api-nominated The issue / PR has been nominated for discussion during a libs-api team meeting. label May 14, 2024
@m-ou-se m-ou-se added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels May 15, 2024
@joshtriplett
Copy link
Member

We discussed this in today's @rust-lang/libs meeting. We were generally in favor of panicking in set_extension here.

(We were hesitant to advocate the same for set_file_name because there might be existing code out there that depends on being able to pass things with path separators there. Though if we were confident that were not the case we'd love to do that too.)

@rfcbot merge

@rfcbot
Copy link

rfcbot commented May 15, 2024

Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels May 15, 2024
@Amanieu Amanieu removed I-libs-nominated The issue / PR has been nominated for discussion during a libs team meeting. I-libs-api-nominated The issue / PR has been nominated for discussion during a libs-api team meeting. labels May 15, 2024
@rfcbot rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels May 15, 2024
@rfcbot
Copy link

rfcbot commented May 15, 2024

🔔 This is now entering its final comment period, as per the review above. 🔔

@tbu-

This comment was marked as off-topic.

Copy link
Member

@jhpratt jhpratt left a comment

Choose a reason for hiding this comment

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

r=me upon FCP completion

@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels May 25, 2024
@rfcbot
Copy link

rfcbot commented May 25, 2024

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

@dtolnay
Copy link
Member

dtolnay commented May 25, 2024

@bors r=jhpratt

@bors
Copy link
Contributor

bors commented May 25, 2024

📌 Commit 700b3ea has been approved by jhpratt

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 May 25, 2024
fmease added a commit to fmease/rust that referenced this pull request May 26, 2024
…ratt

Panic if `PathBuf::set_extension` would add a path separator

This is likely never intended and potentially a security vulnerability if it happens.

I'd guess that it's mostly literal strings that are passed to this function in practice, so I'm guessing this doesn't break anyone.

CC rust-lang#125060
bors added a commit to rust-lang-ci/rust that referenced this pull request May 26, 2024
Rollup of 8 pull requests

Successful merges:

 - rust-lang#125070 (Panic if `PathBuf::set_extension` would add a path separator)
 - rust-lang#125307 (tidy: stop special-casing tests/ui entry limit)
 - rust-lang#125375 (Create a triagebot ping group for Rust for Linux)
 - rust-lang#125413 (drop region constraints for ambiguous goals)
 - rust-lang#125433 (A small diagnostic improvement for dropping_copy_types)
 - rust-lang#125508 (Stop SRoA'ing `DynMetadata` in MIR)
 - rust-lang#125530 (cleanup dependence of `ExtCtxt` in transcribe when macro expansion)
 - rust-lang#125544 (Also mention my-self for other check-cfg docs changes)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors
Copy link
Contributor

bors commented May 26, 2024

⌛ Testing commit 700b3ea with merge f016754...

bors added a commit to rust-lang-ci/rust that referenced this pull request May 26, 2024
Panic if `PathBuf::set_extension` would add a path separator

This is likely never intended and potentially a security vulnerability if it happens.

I'd guess that it's mostly literal strings that are passed to this function in practice, so I'm guessing this doesn't break anyone.

CC rust-lang#125060
@fmease
Copy link
Member

fmease commented May 26, 2024

@bors retry (yield to rollup which includes this PR and which just failed due to network issues)

bors added a commit to rust-lang-ci/rust that referenced this pull request May 26, 2024
Rollup of 8 pull requests

Successful merges:

 - rust-lang#125070 (Panic if `PathBuf::set_extension` would add a path separator)
 - rust-lang#125307 (tidy: stop special-casing tests/ui entry limit)
 - rust-lang#125375 (Create a triagebot ping group for Rust for Linux)
 - rust-lang#125413 (drop region constraints for ambiguous goals)
 - rust-lang#125433 (A small diagnostic improvement for dropping_copy_types)
 - rust-lang#125508 (Stop SRoA'ing `DynMetadata` in MIR)
 - rust-lang#125530 (cleanup dependence of `ExtCtxt` in transcribe when macro expansion)
 - rust-lang#125544 (Also mention my-self for other check-cfg docs changes)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors
Copy link
Contributor

bors commented May 26, 2024

⌛ Testing commit 700b3ea with merge bd184cc...

@bors
Copy link
Contributor

bors commented May 26, 2024

☀️ Test successful - checks-actions
Approved by: jhpratt
Pushing bd184cc to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 26, 2024
@bors bors merged commit bd184cc into rust-lang:master May 26, 2024
7 checks passed
@rustbot rustbot added this to the 1.80.0 milestone May 26, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (bd184cc): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

Results (primary 0.2%, secondary 0.5%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.2% [0.0%, 0.5%] 11
Regressions ❌
(secondary)
0.5% [0.3%, 0.6%] 38
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [0.0%, 0.5%] 11

Bootstrap: 672.481s -> 671.39s (-0.16%)
Artifact size: 315.71 MiB -> 315.55 MiB (-0.05%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. to-announce Announce this issue on triage meeting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet