Skip to content

fix(unicode): prevent USHORT overflow and null-terminator buffer over…#8

Merged
TorinKS merged 1 commit intomainfrom
change/fix-unicode-string-overflow
Mar 22, 2026
Merged

fix(unicode): prevent USHORT overflow and null-terminator buffer over…#8
TorinKS merged 1 commit intomainfrom
change/fix-unicode-string-overflow

Conversation

@TorinKS
Copy link
Copy Markdown
Owner

@TorinKS TorinKS commented Mar 22, 2026

…write

RtlInitUnicodeString: cap MaximumLength to avoid USHORT overflow when Length == UNICODE_STRING_MAX_BYTES (65534 + 2 = 65536 wraps to 0).

RtlAppendUnicodeToString, RtlAppendUnicodeStringToString: change null-terminator guard from (Length < MaximumLength) to (Length + sizeof(WCHAR) <= MaximumLength) to ensure a full WCHAR fits before writing, preventing out-of-bounds write.

…write

RtlInitUnicodeString: cap MaximumLength to avoid USHORT overflow when
Length == UNICODE_STRING_MAX_BYTES (65534 + 2 = 65536 wraps to 0).

RtlAppendUnicodeToString, RtlAppendUnicodeStringToString: change
null-terminator guard from (Length < MaximumLength) to
(Length + sizeof(WCHAR) <= MaximumLength) to ensure a full WCHAR
fits before writing, preventing out-of-bounds write.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@TorinKS TorinKS merged commit a5cdde9 into main Mar 22, 2026
1 check passed
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.

1 participant