Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when mode is to big in fs.createWriteStream #37430

Closed
coderaiser opened this issue Feb 18, 2021 · 1 comment
Closed

Crash when mode is to big in fs.createWriteStream #37430

coderaiser opened this issue Feb 18, 2021 · 1 comment
Labels
confirmed-bug Issues with confirmed bugs. fs Issues and PRs related to the fs subsystem / file system.

Comments

@coderaiser
Copy link
Contributor

  • Version: v14.15.4, v15.9.0
  • Platform: Ubuntu, Mac OS
  • Subsystem: fs

What steps will reproduce the bug?

Node.js crashes on such code:

const {createWriteStream} = require('fs');

createWriteStream('./1.txt', {
    mode: 2176057344,
});

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

Expected to throw, like it happen when mode is 111111111111111:

node:internal/validators:102
      throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value);
      ^

RangeError [ERR_OUT_OF_RANGE]: The value of "mode" is out of range. It must be >= 0 && <= 4294967295. Received 111_111_111_111_111
    at parseFileMode (node:internal/validators:68:5)
    at Object.open (node:fs:473:12)
    at WriteStream._construct (node:internal/fs/streams:64:17)
    at constructNT (node:internal/streams/destroy:288:25)
    at processTicksAndRejections (node:internal/process/task_queues:80:21) {
  code: 'ERR_OUT_OF_RANGE'
}

What do you see instead?

I see a crash:

node[70201]: ../src/node_file.cc:1715:void node::fs::Open(const FunctionCallbackInfo<v8::Value> &): Assertion `args[2]->IsInt32()' failed.
 1: 0x1012e4da5 node::Abort() (.cold.1) [/Users/coderaiser/.nvm/versions/node/v14.15.4/bin/node]
 2: 0x1000a6239 node::Abort() [/Users/coderaiser/.nvm/versions/node/v14.15.4/bin/node]
 3: 0x1000a60a1 node::Assert(node::AssertionInfo const&) [/Users/coderaiser/.nvm/versions/node/v14.15.4/bin/node]
 4: 0x1000ae8d2 node::fs::Open(v8::FunctionCallbackInfo<v8::Value> const&) [/Users/coderaiser/.nvm/versions/node/v14.15.4/bin/node]
 5: 0x10025a4e8 v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo) [/Users/coderaiser/.nvm/versions/node/v14.15.4/bin/node]
 6: 0x100259a7c v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/Users/coderaiser/.nvm/versions/node/v14.15.4/bin/node]
 7: 0x1002591a2 v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/Users/coderaiser/.nvm/versions/node/v14.15.4/bin/node]
 8: 0x100a7a359 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit [/Users/coderaiser/.nvm/versions/node/v14.15.4/bin/node]
Abort trap: 6

Additional information

@targos targos added confirmed-bug Issues with confirmed bugs. fs Issues and PRs related to the fs subsystem / file system. labels Feb 18, 2021
RaisinTen added a commit to RaisinTen/node that referenced this issue Feb 18, 2021
RaisinTen added a commit to RaisinTen/node that referenced this issue Feb 18, 2021
jasnell added a commit to jasnell/node that referenced this issue Feb 22, 2021
The `flag` and `mode` options were not being validated correctly.

Signed-off-by: James M Snell <jasnell@gmail.com>
Fixes: nodejs#37430
@jasnell
Copy link
Member

jasnell commented Feb 22, 2021

PR: #37480

jasnell added a commit to jasnell/node that referenced this issue Feb 25, 2021
The `flag` and `mode` options were not being validated correctly.

Signed-off-by: James M Snell <jasnell@gmail.com>
Fixes: nodejs#37430
jasnell added a commit to jasnell/node that referenced this issue Feb 26, 2021
The `flag` and `mode` options were not being validated correctly.

Signed-off-by: James M Snell <jasnell@gmail.com>
Fixes: nodejs#37430
jasnell added a commit to jasnell/node that referenced this issue Feb 26, 2021
The `flag` and `mode` options were not being validated correctly.

Signed-off-by: James M Snell <jasnell@gmail.com>
Fixes: nodejs#37430
jasnell added a commit to jasnell/node that referenced this issue Feb 26, 2021
The `flag` and `mode` options were not being validated correctly.

Signed-off-by: James M Snell <jasnell@gmail.com>
Fixes: nodejs#37430
jasnell added a commit to jasnell/node that referenced this issue Feb 26, 2021
The `flag` and `mode` options were not being validated correctly.

Signed-off-by: James M Snell <jasnell@gmail.com>
Fixes: nodejs#37430
@jasnell jasnell closed this as completed in da217d0 Mar 1, 2021
lpinca pushed a commit to lpinca/node that referenced this issue Mar 2, 2021
The `flag` and `mode` options were not being validated correctly.

Signed-off-by: James M Snell <jasnell@gmail.com>
Fixes: nodejs#37430

PR-URL: nodejs#37480
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants