GeezerVison is showing github.com — src: CHECK() for argument overflow in Spawn() · nodejs/node@bce5db2
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/process_wrap.cc +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -185,6 +185,8 @@ class ProcessWrap : public HandleWrap { |
185 | 185 | if (!argv_v.IsEmpty() && argv_v->IsArray()) { |
186 | 186 | Local<Array> js_argv = Local<Array>::Cast(argv_v); |
187 | 187 | int argc = js_argv->Length(); |
| 188 | + CHECK_GT(argc + 1, 0); // Check for overflow. |
| 189 | + |
188 | 190 | // Heap allocate to detect errors. +1 is for nullptr. |
189 | 191 | options.args = new char*[argc + 1]; |
190 | 192 | for (int i = 0; i < argc; i++) { |
@@ -211,6 +213,7 @@ class ProcessWrap : public HandleWrap { |
211 | 213 | if (!env_v.IsEmpty() && env_v->IsArray()) { |
212 | 214 | Local<Array> env_opt = Local<Array>::Cast(env_v); |
213 | 215 | int envc = env_opt->Length(); |
| 216 | + CHECK_GT(envc + 1, 0); // Check for overflow. |
214 | 217 | options.env = new char*[envc + 1]; // Heap allocated to detect errors. |
215 | 218 | for (int i = 0; i < envc; i++) { |
216 | 219 | node::Utf8Value pair(env->isolate(), |
|