Skip to content

Fix UB in NtUnicodeStrMut::try_from_u16()#2

Merged
ColinFinck merged 2 commits into
ColinFinck:masterfrom
smichaku:fix-try_from_u16
May 16, 2026
Merged

Fix UB in NtUnicodeStrMut::try_from_u16()#2
ColinFinck merged 2 commits into
ColinFinck:masterfrom
smichaku:fix-try_from_u16

Conversation

@smichaku
Copy link
Copy Markdown
Contributor

Avoid transmuting an NtUnicodeStr into a NtUnicodeStrMut which is assigned a *const instead of a *mut for its buffer field.

Avoid transmuting an NtUnicodeStr into a NtUnicodeStrMut which is
assigned a *const instead of a *mut for its buffer field.
@ColinFinck ColinFinck merged commit 8dd7058 into ColinFinck:master May 16, 2026
1 check passed
@ColinFinck
Copy link
Copy Markdown
Owner

Hey @smichaku, thanks a lot for your PR! This doesn't only fix the UB you reported in #1, but also eliminates a few unsafe blocks that needed explanation via SAFETY comments.
I was very happy to see that your PR fixes this without duplicating any code.

I took the liberty to move your newly added functions back to NtUnicodeStr, but otherwise merged the PR as-is.
Thanks again!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants