Skip to content

fs: throw on out-of-bounds buffers in read and write bindings - #67583

Open
ShogunPanda wants to merge 1 commit into
nodejs:mainfrom
ShogunPanda:fs-buffer-bounds-error
Open

ShogunPanda wants to merge 1 commit into
nodejs:mainfrom
ShogunPanda:fs-buffer-bounds-error

Conversation

@ShogunPanda

Copy link
Copy Markdown
Contributor

Summary

Prevent process termination when fs native bindings receive a buffer whose JavaScript-visible byteLength exceeds its real backing-store size. Invalid ranges now produce a catchable ERR_OUT_OF_RANGE error.

Changes

  • Replace fatal read and write buffer bounds assertions with explicit range errors.
  • Add regression coverage for synchronous, callback, and promise-based read and write paths.

Additional Informations

AI-assisted work. All changes reviewed by a human.

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to file-system APIs and the fs module. needs-ci PRs that need a full CI run. labels Nov 18, 2026
@jasnell jasnell added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 22, 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 Nov 22, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as resolved.

@jasnell jasnell added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 26, 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 Nov 26, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@ShogunPanda ShogunPanda added the commit-queue PRs queued for automated landing through the Commit Queue. label Dec 3, 2026
@nodejs-github-bot nodejs-github-bot added commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. and removed commit-queue PRs queued for automated landing through the Commit Queue. labels Dec 3, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Commit Queue failed

   ✖  1 GitHub CI job(s) failed:
   ✖    - coverage-windows: FAILURE (https://github.com/nodejs/node/actions/runs/44325696450/job/134876238609)
   ✖  1 GitHub CI job(s) cancelled:
   ✖    - build-tarball: CANCELLED (https://github.com/nodejs/node/actions/runs/44325696342/job/134876238735)

The pull request was removed from the Commit Queue and labeled commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. . After resolving the failure, remove that label and add commit-queue PRs queued for automated landing through the Commit Queue. to retry.

Full Commit Queue output
�[36m⠋�[39m Loading data for nodejs/node/pull/67583
�[36m⠋�[39m Loading data for nodejs/node/pull/67583
�[36m⠋�[39m Getting collaborator contacts from README of nodejs/node
�[36m⠋�[39m Getting PR from nodejs/node/pull/67583
�[36m⠋�[39m Getting reviews from nodejs/node/pull/67583
�[36m⠋�[39m Getting comments from nodejs/node/pull/67583
�[36m⠋�[39m Getting commits from nodejs/node/pull/67583
✔  Done loading data for nodejs/node/pull/67583
----------------------------------- PR info ------------------------------------
Title      fs: throw on out-of-bounds buffers in read and write bindings (#67583)
Author     Paolo Insogna <paolo@cowtech.it> (@ShogunPanda)
Branch     ShogunPanda:fs-buffer-bounds-error -> nodejs:main
Labels     c++, fs, needs-ci, commit-queue
Commits    1
 - fs: throw on out-of-bounds buffers in read and write bindings
Committers 1
 - Paolo Insogna <paolo@cowtech.it>
PR-URL: https://github.com/nodejs/node/pull/67583
Reviewed-By: James M Snell <jasnell@gmail.com>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/67583
Reviewed-By: James M Snell <jasnell@gmail.com>
--------------------------------------------------------------------------------
   ℹ  This PR was created on Wed, 18 Nov 2026 14:34:09 GMT
   ✔  Approvals: 1
   ✔  - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/67583#pullrequestreview-6013768715
   ✖  1 GitHub CI job(s) failed:
   ✖    - coverage-windows: FAILURE (https://github.com/nodejs/node/actions/runs/44325696450/job/134876238609)
   ✖  1 GitHub CI job(s) cancelled:
   ✖    - build-tarball: CANCELLED (https://github.com/nodejs/node/actions/runs/44325696342/job/134876238735)
   ℹ  Last Full PR CI on 2026-11-26T16:40:33Z: https://ci.nodejs.org/job/node-test-pull-request/79510/
�[36m⠙�[39m Querying data for job/node-test-pull-request/79510/
�[36m⠙�[39m Querying data for job/node-test-pull-request/79510/
�[36m⠙�[39m Querying API for job/node-test-pull-request/79510/
✔  Build data downloaded
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu

View workflow run

@StefanStojanovic

Copy link
Copy Markdown
Contributor

Coverage Windows issue should be resolved by rebasing to main.

Replace the fatal bounds assertions in the WriteBuffer and Read
bindings with ERR_OUT_OF_RANGE errors, so a buffer whose
JavaScript-visible byteLength exceeds its backing store no longer
aborts the process.

Assisted-By: OpenAI GPT-5.6 Sol <openai/gpt-5.6-sol>
Signed-off-by: Paolo Insogna <paolo@cowtech.it>
@ShogunPanda
ShogunPanda force-pushed the fs-buffer-bounds-error branch from 5e78a47 to b88318f Compare December 4, 2026 12:34
@codecov

codecov Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.57%. Comparing base (0c5be9d) to head (b88318f).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67583      +/-   ##
==========================================
- Coverage   90.59%   90.57%   -0.02%     
==========================================
  Files         802      802              
  Lines      287040   287038       -2     
  Branches    55432    55420      -12     
==========================================
- Hits       260031   259994      -37     
- Misses      17098    17119      +21     
- Partials     9911     9925      +14     
Files with missing lines Coverage Δ
src/node_file.cc 76.85% <100.00%> (+0.07%) ⬆️

... and 27 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.

@ShogunPanda ShogunPanda added request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. and removed commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. labels Dec 4, 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 Dec 4, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

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

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to file-system APIs and the fs module. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants