projects
/
platform
/
upstream
/
nsjail.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
2044488
)
net/cmdline: better checks for TCP port values
author
Robert Swiecki
<robert@swiecki.net>
Mon, 19 Aug 2019 09:34:34 +0000
(11:34 +0200)
committer
Robert Swiecki
<robert@swiecki.net>
Mon, 19 Aug 2019 09:34:34 +0000
(11:34 +0200)
cmdline.cc
patch
|
blob
|
history
net.cc
patch
|
blob
|
history
diff --git
a/cmdline.cc
b/cmdline.cc
index ed31a620c7fbde0ddd1ea206897536967ce8ae97..91dae4e75aa9ab98e062eb80c0ae543a7d84efb2 100644
(file)
--- a/
cmdline.cc
+++ b/
cmdline.cc
@@
-487,6
+487,10
@@
std::unique_ptr<nsjconf_t> parseArgs(int argc, char* argv[]) {
nsjconf->chroot = optarg;
break;
case 'p':
+ if (!util::isANumber(optarg)) {
+ LOG_E("Couldn't parse TCP port '%s'", optarg);
+ return nullptr;
+ }
nsjconf->port = strtoumax(optarg, NULL, 0);
nsjconf->mode = MODE_LISTEN_TCP;
break;
diff --git
a/net.cc
b/net.cc
index 922002234863d00b815fe08c91cc5fa89d937b47..6e5745a7e15577a2a44097b6d0789849c59fe651 100644
(file)
--- a/
net.cc
+++ b/
net.cc
@@
-205,7
+205,7
@@
bool limitConns(nsjconf_t* nsjconf, int connsock) {
}
int getRecvSocket(const char* bindhost, int port) {
- if (port <
1
|| port > 65535) {
+ if (port <
0
|| port > 65535) {
LOG_F(
"TCP port %d out of bounds (0 <= port <= 65535), specify one with --port "
"<port>",