Skip to content

Make convert_while_ascii unsafe#155305

Open
Zoxc wants to merge 1 commit intorust-lang:mainfrom
Zoxc:ub-issue-2
Open

Make convert_while_ascii unsafe#155305
Zoxc wants to merge 1 commit intorust-lang:mainfrom
Zoxc:ub-issue-2

Conversation

@Zoxc
Copy link
Copy Markdown
Contributor

@Zoxc Zoxc commented Apr 14, 2026

convert_while_ascii assumes convert only returns ASCII to ensure the output remains valid UTF-8. This adds that requirement as a safety precondition.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 14, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 14, 2026

r? @ibraheemdev

rustbot has assigned @ibraheemdev.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 7 candidates
  • Random selection from Mark-Simulacrum, ibraheemdev

@Bryntet
Copy link
Copy Markdown
Contributor

Bryntet commented Apr 14, 2026

Could you explain a bit more on how you could get UB by calling convert_while_ascii? This isn't too clear based on your PR description

@Bryntet
Copy link
Copy Markdown
Contributor

Bryntet commented Apr 14, 2026

also you should probably reroll, see #155303

@Zoxc
Copy link
Copy Markdown
Contributor Author

Zoxc commented Apr 14, 2026

Could you explain a bit more on how you could get UB by calling convert_while_ascii?

The output of convert is placed unchecked in the out vector which later is passed to String::from_utf8_unchecked.

Copy link
Copy Markdown
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. 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