summaryrefslogtreecommitdiff
path: root/src/node_process_object.cc
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2021-04-11 12:22:43 -0400
committerJames M Snell <jasnell@gmail.com>2021-04-12 15:05:08 -0700
commit13c931a9dc7ac95bbe22e62361241bdb94227452 (patch)
treea8fb3945b8dde9b3705dfcfb5eb703e0b797a62e /src/node_process_object.cc
parent756d2e48d8fcbd0dc909e7ad108a495b890c64f1 (diff)
downloadnode-new-13c931a9dc7ac95bbe22e62361241bdb94227452.tar.gz
process: add range validation to debugPort
This commit adds validation to the process.debugPort setter. Fixes: https://github.com/nodejs/node/issues/38037 PR-URL: https://github.com/nodejs/node/pull/38205 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
Diffstat (limited to 'src/node_process_object.cc')
-rw-r--r--src/node_process_object.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/node_process_object.cc b/src/node_process_object.cc
index 4648cfbd11..3d573d5346 100644
--- a/src/node_process_object.cc
+++ b/src/node_process_object.cc
@@ -1,4 +1,5 @@
#include "env-inl.h"
+#include "node_errors.h"
#include "node_external_reference.h"
#include "node_internals.h"
#include "node_metadata.h"
@@ -60,6 +61,13 @@ static void DebugPortSetter(Local<Name> property,
const PropertyCallbackInfo<void>& info) {
Environment* env = Environment::GetCurrent(info);
int32_t port = value->Int32Value(env->context()).FromMaybe(0);
+
+ if ((port != 0 && port < 1024) || port > 65535) {
+ return THROW_ERR_OUT_OF_RANGE(
+ env,
+ "process.debugPort must be 0 or in range 1024 to 65535");
+ }
+
ExclusiveAccess<HostPort>::Scoped host_port(env->inspector_host_port());
host_port->set_port(static_cast<int>(port));
}