Skip to content

Commit ce9caa2

Browse files
committed
Fix #1563. overflow in ChildProcess custom_fd.
Backported from master f5db3f1
1 parent e150bc4 commit ce9caa2

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/node_child_process.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,13 @@ Handle<Value> ChildProcess::Spawn(const Arguments& args) {
164164
if (args[4]->IsArray()) {
165165
// Set the custom file descriptor values (if any) for the child process
166166
Local<Array> custom_fds_handle = Local<Array>::Cast(args[4]);
167+
167168
int custom_fds_len = custom_fds_handle->Length();
169+
// Bound by 3.
170+
if (custom_fds_len > 3) {
171+
custom_fds_len = 3;
172+
}
173+
168174
for (int i = 0; i < custom_fds_len; i++) {
169175
if (custom_fds_handle->Get(i)->IsUndefined()) continue;
170176
Local<Integer> fd = custom_fds_handle->Get(i)->ToInteger();
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var common = require('../common');
2+
var spawn = require('child_process').spawn;
3+
var bigish = Array(200);
4+
5+
for (var i = 0, il = bigish.length; i < il; ++i)
6+
bigish[i] = -1;
7+
8+
spawn('/bin/echo', [], { customFds: bigish });
9+

0 commit comments

Comments
 (0)