nghttpd: Check maximum value of -c option
This commit is contained in:
parent
3ec71bf5a2
commit
751d66a397
|
@ -282,14 +282,20 @@ int main(int argc, char **argv) {
|
||||||
case 'v':
|
case 'v':
|
||||||
config.verbose = true;
|
config.verbose = true;
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c': {
|
||||||
errno = 0;
|
auto n = util::parse_uint_with_unit(optarg);
|
||||||
config.header_table_size = util::parse_uint_with_unit(optarg);
|
if (n == -1) {
|
||||||
if (config.header_table_size == -1) {
|
|
||||||
std::cerr << "-c: Bad option value: " << optarg << std::endl;
|
std::cerr << "-c: Bad option value: " << optarg << std::endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
if (n > std::numeric_limits<uint32_t>::max()) {
|
||||||
|
std::cerr << "-c: Value too large. It should be less than or equal to "
|
||||||
|
<< std::numeric_limits<uint32_t>::max() << std::endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
config.header_table_size = n;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 'p':
|
case 'p':
|
||||||
if (parse_push_config(config, optarg) != 0) {
|
if (parse_push_config(config, optarg) != 0) {
|
||||||
std::cerr << "-p: Bad option value: " << optarg << std::endl;
|
std::cerr << "-p: Bad option value: " << optarg << std::endl;
|
||||||
|
|
Loading…
Reference in New Issue