Permalink
Browse files

Fix #1563. overflow in ChildProcess custom_fd.

Backported from master f5db3f1
  • Loading branch information...
1 parent e150bc4 commit ce9caa237fe730ecf18cc96f4a176352a1b1a2dc @ry ry committed Aug 20, 2011
Showing with 15 additions and 0 deletions.
  1. +6 −0 src/node_child_process.cc
  2. +9 −0 test/simple/test-child-process-customfd-bounded.js
@@ -164,7 +164,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();
@@ -0,0 +1,9 @@
+var common = require('../common');
+var spawn = require('child_process').spawn;
+var bigish = Array(200);
+
+for (var i = 0, il = bigish.length; i < il; ++i)
+ bigish[i] = -1;
+
+spawn('/bin/echo', [], { customFds: bigish });
+

0 comments on commit ce9caa2

Please sign in to comment.