summaryrefslogtreecommitdiff
path: root/src/node_debug_options.cc
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2017-05-27 13:31:00 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2017-05-30 12:22:02 +0200
commit399cb25f6266a17f0e5ed838b37b9c8299a87224 (patch)
tree0ef6c616fa42b20dfd1e5fdb496e15e5c1e12775 /src/node_debug_options.cc
parentc420cd15403e374111150d46f209211c3289f9f4 (diff)
downloadandroid-node-v8-399cb25f6266a17f0e5ed838b37b9c8299a87224.tar.gz
android-node-v8-399cb25f6266a17f0e5ed838b37b9c8299a87224.tar.bz2
android-node-v8-399cb25f6266a17f0e5ed838b37b9c8299a87224.zip
inspector: bind to random port with --inspect=0
Allow binding to a randomly assigned port number with `--inspect=0` or `--inspect-brk=0`. PR-URL: https://github.com/nodejs/node/pull/5025 Refs: https://github.com/nodejs/node/issues/4419 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Diffstat (limited to 'src/node_debug_options.cc')
-rw-r--r--src/node_debug_options.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/node_debug_options.cc b/src/node_debug_options.cc
index 3f1a2e56e8..d82e92170a 100644
--- a/src/node_debug_options.cc
+++ b/src/node_debug_options.cc
@@ -21,8 +21,9 @@ int parse_and_validate_port(const std::string& port) {
char* endptr;
errno = 0;
const long result = strtol(port.c_str(), &endptr, 10); // NOLINT(runtime/int)
- if (errno != 0 || *endptr != '\0'|| result < 1024 || result > 65535) {
- fprintf(stderr, "Debug port must be in range 1024 to 65535.\n");
+ if (errno != 0 || *endptr != '\0'||
+ (result != 0 && result < 1024) || result > 65535) {
+ fprintf(stderr, "Debug port must be 0 or in range 1024 to 65535.\n");
exit(12);
}
return static_cast<int>(result);