Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Fix #1563. overflow in ChildProcess custom_fd.
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Aug 20, 2011
1 parent 962a9e8 commit f5db3f1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/node_child_process.cc
Expand Up @@ -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();
Expand Down
8 changes: 8 additions & 0 deletions 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 });

0 comments on commit f5db3f1

Please sign in to comment.