Browse Source

Fix #1563. overflow in ChildProcess custom_fd.

Ryan Dahl 14 years ago
parent
commit
f5db3f1f85
  1. 6
      src/node_child_process.cc
  2. 8
      test/simple/test-child-process-customfd-bounded.js

6
src/node_child_process.cc

@ -167,7 +167,13 @@ Handle<Value> ChildProcess::Spawn(const Arguments& args) {
if (args[4]->IsArray()) {
// Set the custom file descriptor values (if any) for the child process
Local<Array> custom_fds_handle = Local<Array>::Cast(args[4]);
int custom_fds_len = custom_fds_handle->Length();
// Bound by 3.
if (custom_fds_len > 3) {
custom_fds_len = 3;
}
for (int i = 0; i < custom_fds_len; i++) {
if (custom_fds_handle->Get(i)->IsUndefined()) continue;
Local<Integer> fd = custom_fds_handle->Get(i)->ToInteger();

8
test/simple/test-child-process-customfd-bounded.js

@ -0,0 +1,8 @@
var common = require('../common');
var bigish = Array(200);
for (var i = 0, il = bigish.length; i < il; ++i)
bigish[i] = -1;
common.spawnPwd({ customFds: bigish });
Loading…
Cancel
Save