Skip to content

Comments

Fix #55422: Buffer.concat and Buffer.copy silently produce invalid r#61914

Open
danielalanbates wants to merge 2 commits intonodejs:mainfrom
danielalanbates:fix/issue-55422
Open

Fix #55422: Buffer.concat and Buffer.copy silently produce invalid r#61914
danielalanbates wants to merge 2 commits intonodejs:mainfrom
danielalanbates:fix/issue-55422

Conversation

@danielalanbates
Copy link

@danielalanbates danielalanbates commented Feb 21, 2026

Fixes: #55422

Summary

This PR fixes: Buffer.concat and Buffer.copy silently produce invalid results when the operation involves indices equal or greater than 2^32

Changes

src/node_buffer.cc                      | 24 ++++++++++++------
 test/parallel/test-buffer-copy-large.js | 44 +++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+), 8 deletions(-)

Testing

Please review the changes carefully. The fix was verified against the existing test suite.


This PR was created with the assistance of Claude Sonnet 4.6 by Anthropic | effort: high. Happy to make any adjustments!

@nodejs-github-bot nodejs-github-bot added buffer Issues and PRs related to the buffer subsystem. c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Feb 21, 2026
@codecov
Copy link

codecov bot commented Feb 21, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.77%. Comparing base (f632f3f) to head (723a5cc).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/node_buffer.cc 66.66% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #61914      +/-   ##
==========================================
- Coverage   91.70%   89.77%   -1.94%     
==========================================
  Files         337      674     +337     
  Lines      140104   204889   +64785     
  Branches    21758    39390   +17632     
==========================================
+ Hits       128484   183935   +55451     
- Misses      11398    13231    +1833     
- Partials      222     7723    +7501     
Files with missing lines Coverage Δ
src/node_buffer.cc 67.77% <66.66%> (ø)

... and 458 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Change FastCopy argument types and return type from uint32_t to
uint64_t to be consistent with CopyImpl which uses size_t.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@danielalanbates
Copy link
Author

Thanks for the feedback, @Renegade334! I've pushed an update addressing your review comments. Please take another look when you get a chance.

@Renegade334
Copy link
Member

Mostly good, modulo:

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

Labels

buffer Issues and PRs related to the buffer subsystem. c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Buffer.concat and Buffer.copy silently produce invalid results when the operation involves indices equal or greater than 2^32

3 participants