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

Commit f5db3f1

Browse files
committed
Fix #1563. overflow in ChildProcess custom_fd.
1 parent 962a9e8 commit f5db3f1

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/node_child_process.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,13 @@ Handle<Value> ChildProcess::Spawn(const Arguments& args) {
167167
if (args[4]->IsArray()) {
168168
// Set the custom file descriptor values (if any) for the child process
169169
Local<Array> custom_fds_handle = Local<Array>::Cast(args[4]);
170+
170171
int custom_fds_len = custom_fds_handle->Length();
172+
// Bound by 3.
173+
if (custom_fds_len > 3) {
174+
custom_fds_len = 3;
175+
}
176+
171177
for (int i = 0; i < custom_fds_len; i++) {
172178
if (custom_fds_handle->Get(i)->IsUndefined()) continue;
173179
Local<Integer> fd = custom_fds_handle->Get(i)->ToInteger();
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
var common = require('../common');
2+
var bigish = Array(200);
3+
4+
for (var i = 0, il = bigish.length; i < il; ++i)
5+
bigish[i] = -1;
6+
7+
common.spawnPwd({ customFds: bigish });
8+

0 commit comments

Comments
 (0)