Commit d6db38a3 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttpx: Clean up integer configuration range checking

parent c88a5291
...@@ -1075,8 +1075,8 @@ int parse_config(const char *opt, const char *optarg) { ...@@ -1075,8 +1075,8 @@ int parse_config(const char *opt, const char *optarg) {
return -1; return -1;
} }
if (n < 1) { if (n == 0) {
LOG(ERROR) << opt << ": specify the integer more than or equal to 1"; LOG(ERROR) << opt << ": specify an integer strictly more than 0";
return -1; return -1;
} }
...@@ -1087,21 +1087,8 @@ int parse_config(const char *opt, const char *optarg) { ...@@ -1087,21 +1087,8 @@ int parse_config(const char *opt, const char *optarg) {
} }
if (util::strieq(opt, SHRPX_OPT_BACKEND_HTTP1_CONNECTIONS_PER_FRONTEND)) { if (util::strieq(opt, SHRPX_OPT_BACKEND_HTTP1_CONNECTIONS_PER_FRONTEND)) {
int n; return parse_uint(&mod_config()->downstream_connections_per_frontend, opt,
optarg);
if (parse_uint(&n, opt, optarg) != 0) {
return -1;
}
if (n < 0) {
LOG(ERROR) << opt << ": specify the integer more than or equal to 0";
return -1;
}
mod_config()->downstream_connections_per_frontend = n;
return 0;
} }
if (util::strieq(opt, SHRPX_OPT_LISTENER_DISABLE_TIMEOUT)) { if (util::strieq(opt, SHRPX_OPT_LISTENER_DISABLE_TIMEOUT)) {
...@@ -1139,6 +1126,7 @@ int parse_config(const char *opt, const char *optarg) { ...@@ -1139,6 +1126,7 @@ int parse_config(const char *opt, const char *optarg) {
if (n == 0) { if (n == 0) {
LOG(ERROR) << opt << ": specify an integer strictly more than 0"; LOG(ERROR) << opt << ": specify an integer strictly more than 0";
return -1; return -1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment