Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8d31294

Browse filesBrowse files
cjihrigMylesBorins
authored andcommitted
src: CHECK() for argument overflow in Spawn()
This commit adds checks for overflow to args and env in Spawn(). It seems extremely unlikely that either of these values would overflow from a valid use case. Fixes: #15622 PR-URL: #16761 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
1 parent 2f1f7e1 commit 8d31294
Copy full SHA for 8d31294

File tree

Expand file treeCollapse file tree

1 file changed

+3
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-0
lines changed
Open diff view settings
Collapse file

‎src/process_wrap.cc‎

Copy file name to clipboardExpand all lines: src/process_wrap.cc
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ class ProcessWrap : public HandleWrap {
185185
if (!argv_v.IsEmpty() && argv_v->IsArray()) {
186186
Local<Array> js_argv = Local<Array>::Cast(argv_v);
187187
int argc = js_argv->Length();
188+
CHECK_GT(argc + 1, 0); // Check for overflow.
189+
188190
// Heap allocate to detect errors. +1 is for nullptr.
189191
options.args = new char*[argc + 1];
190192
for (int i = 0; i < argc; i++) {
@@ -211,6 +213,7 @@ class ProcessWrap : public HandleWrap {
211213
if (!env_v.IsEmpty() && env_v->IsArray()) {
212214
Local<Array> env_opt = Local<Array>::Cast(env_v);
213215
int envc = env_opt->Length();
216+
CHECK_GT(envc + 1, 0); // Check for overflow.
214217
options.env = new char*[envc + 1]; // Heap allocated to detect errors.
215218
for (int i = 0; i < envc; i++) {
216219
node::Utf8Value pair(env->isolate(),

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.