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':
|
||||
config.verbose = true;
|
||||
break;
|
||||
case 'c':
|
||||
errno = 0;
|
||||
config.header_table_size = util::parse_uint_with_unit(optarg);
|
||||
if (config.header_table_size == -1) {
|
||||
case 'c': {
|
||||
auto n = util::parse_uint_with_unit(optarg);
|
||||
if (n == -1) {
|
||||
std::cerr << "-c: Bad option value: " << optarg << std::endl;
|
||||
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;
|
||||
}
|
||||
case 'p':
|
||||
if (parse_push_config(config, optarg) != 0) {
|
||||
std::cerr << "-p: Bad option value: " << optarg << std::endl;
|
||||
|
|
Loading…
Reference in New Issue