Repository navigation
fs: fix abort on negative zero write length - #67524
christianaurichzm wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #67524 +/- ##
==========================================
+ Coverage 90.71% 90.73% +0.01%
==========================================
Files 801 801
Lines 280906 280912 +6
Branches 54249 54243 -6
==========================================
+ Hits 254832 254878 +46
+ Misses 16246 16208 -38
+ Partials 9828 9826 -2
🚀 New features to boost your workflow:
|
|
Reproduced the crash on main, and on v22, v24 and v26 too. I also tried -0 in the other fs calls (offset, position, read, writev, truncate, streams) and none of them crash, so this PR fixes the only place that still did. LGTM, thanks! |
Commit Queue failedThe pull request was removed from the Commit Queue and labeled
commit-queue-failed
Full Commit Queue output |
`validateOffsetLengthWrite()` accepts -0 as a length, but V8 does not represent -0 as an Int32 value, so the `IsInt32()` check in the binding aborted the process in `fs.write()`, `fs.writeSync()` and `filehandle.write()`. Coerce the validated length to an int32 before the call, as `fs.read()` already does. Signed-off-by: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
a25fb60 to
557b254
Compare
|
Rebased to resolve the conflict with #67567, which changed the top of the same test. Only the test changed. @jasnell @LiviaMedeiros could you take a look? |
fs.write(),fs.writeSync()andfilehandle.write()abort the process when the length is-0, either positional or asoptions.length. This also happens on v22.23.1:validateOffsetLengthWrite()accepts-0, but V8 does not report-0as anInt32, which the binding requires. This coerces the validated length to an int32 before entering the binding, asfs.read()already does, so-0writes nothing, like0.The new block in
test/parallel/test-fs-negative-zero.jsaborts onmainand passes with this change.Refs: #65888