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

Fix a stack buffer overflow in ChildProcess custom_fd handling. #1563

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/node_child_process.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ extern char **environ;

#include <limits.h> /* PATH_MAX */

#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))

namespace node {

using namespace v8;
Expand Down Expand Up @@ -168,7 +170,7 @@ Handle<Value> ChildProcess::Spawn(const Arguments& args) {
// 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();
for (int i = 0; i < custom_fds_len; i++) {
for (int i = 0; i < custom_fds_len && i < ARRAY_SIZE(custom_fds); i++) {
if (custom_fds_handle->Get(i)->IsUndefined()) continue;
Local<Integer> fd = custom_fds_handle->Get(i)->ToInteger();
custom_fds[i] = fd->Value();
Expand Down