fs: coerce FileHandle.read length like fs.read - #65521
Open
bun-unsafe wants to merge 1 commit into
Open
Conversation
Non-number length values reached node::fs::Read, which CHECKs IsInt32() and aborts the process. Apply length |= 0 after defaulting, matching fs.read and fs.readSync. Signed-off-by: Xia Chao <236466140+bun-unsafe@users.noreply.github.com>
lpinca
approved these changes
Aug 24, 2026
Contributor
Failed to start CI- Validating Jenkins credentials ✔ Jenkins credentials valid - Starting PR CI job ✘ Failed to start PR CI: 400 Bad Requesthttps://github.com/nodejs/node/actions/runs/32773413890 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #65521 +/- ##
=======================================
Coverage 90.14% 90.15%
=======================================
Files 751 751
Lines 253585 253586 +1
Branches 47772 47773 +1
=======================================
+ Hits 228596 228620 +24
+ Misses 16228 16204 -24
- Partials 8761 8762 +1
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
fs.promises.FileHandle.read()forwarded a non-numberlength(for example"5") intobinding.read.node::fs::Readrequiresargs[3]->IsInt32()and aborts the process on a debug/CHECK failure.fs.read/fs.readSyncalready coerce withlength |= 0after defaulting. This applies the same step on the promises path so a badlengthcannot reach C++.Test plan
./node test/parallel/test-fs-promises-file-handle-read.jsFileHandle.readcases (empty length, options object,null/undefinedlength) still pass on CI