src: fix out-of-bounds write when transcoding odd-length ucs2 by Nashit-h · Pull Request #64512 · nodejs/node · GitHub
Skip to content

src: fix out-of-bounds write when transcoding odd-length ucs2 - #64512

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
Nashit-h:ucs2-transcode-overflow
Aug 22, 2026
Merged

src: fix out-of-bounds write when transcoding odd-length ucs2#64512
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
Nashit-h:ucs2-transcode-overflow

Conversation

@Nashit-h

Copy link
Copy Markdown
Contributor

CopySourceBuffer sizes its destination for whole UChar units (source_length / sizeof(UChar)) but memcpy's the raw byte length, so Buffer.transcode() of an odd-length utf16le buffer into latin1/ascii writes one byte past the conversion buffer, on both the on-stack and the heap path. Copy only the whole code units so a trailing half byte is ignored; ucnv_fromUChars already consumes length_in_chars units, so the extra byte was never read back. Added an odd-length case to test-icu-transcode.js that trips ASAN on the current code.

Signed-off-by: Nashit-h <nashit@bugqore.com>
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. i18n-api Issues and PRs related to Node.js internationalization support. needs-ci PRs that need a full CI run. labels Jul 15, 2026
@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

@Renegade334 Renegade334 added author ready PRs with CI started, the required approvals, and no outstanding review comments. request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. labels Jul 23, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jul 23, 2026
@nodejs-github-bot

This comment was marked as duplicate.

@Nashit-h

Copy link
Copy Markdown
Contributor Author

This is approved and green everywhere except the shared-libs Jenkins node, which failed on its own while every sibling job (linked-icu, smallicu, withoutintl, openssl, zlib) passed, so it looks like a flaky run rather than anything from this change. Could someone start a fresh CI so it can land?

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@trivikr trivikr added the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 22, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 70c189b into nodejs:main Aug 22, 2026
87 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 22, 2026
aduh95 pushed a commit that referenced this pull request Aug 25, 2026
Signed-off-by: Nashit-h <nashit@bugqore.com>
PR-URL: #64512
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
aduh95 pushed a commit that referenced this pull request Aug 25, 2026
Signed-off-by: Nashit-h <nashit@bugqore.com>
PR-URL: #64512
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
aduh95 pushed a commit that referenced this pull request Aug 27, 2026
Signed-off-by: Nashit-h <nashit@bugqore.com>
PR-URL: #64512
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
aduh95 pushed a commit that referenced this pull request Sep 7, 2026
Signed-off-by: Nashit-h <nashit@bugqore.com>
PR-URL: #64512
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
aduh95 pushed a commit that referenced this pull request Sep 7, 2026
Signed-off-by: Nashit-h <nashit@bugqore.com>
PR-URL: #64512
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. c++ Issues and PRs that require attention from people who are familiar with C++. i18n-api Issues and PRs related to Node.js internationalization support. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants