From f05a4830c5bd99942161663bde216347ab89e5b3 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 28 Apr 2015 21:51:28 +0900 Subject: [PATCH] nghttp: Fix assertion error if very large value is given to -t --- src/nghttp.cc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/nghttp.cc b/src/nghttp.cc index 56e09ec9..49e1825b 100644 --- a/src/nghttp.cc +++ b/src/nghttp.cc @@ -2315,8 +2315,9 @@ Options: filename is dereived from URI. If URI ends with '/', 'index.html' is used as a filename. Not implemented yet. - -t, --timeout= - Timeout each request after seconds. + -t, --timeout= + Timeout each request after . Set 0 to disable + timeout. -w, --window-bits= Sets the stream level initial window size to 2**-1. -W, --connection-window-bits= @@ -2386,7 +2387,12 @@ Options: -- The argument is an integer and an optional unit (e.g., 10K is - 10 * 1024). Units are K, M and G (powers of 1024).)" << std::endl; + 10 * 1024). Units are K, M and G (powers of 1024). + + The argument is an integer and an optional unit (e.g., 1s + is 1 second and 500ms is 500 milliseconds). Units are h, m, s or ms + (hours, minutes, seconds and milliseconds, respectively). If a unit + is omitted, a second is used as unit.)" << std::endl; } } // namespace @@ -2472,7 +2478,11 @@ int main(int argc, char **argv) { ++config.verbose; break; case 't': - config.timeout = atoi(optarg); + config.timeout = util::parse_duration_with_unit(optarg); + if (config.timeout == std::numeric_limits::infinity()) { + std::cerr << "-t: bad timeout value: " << optarg << std::endl; + exit(EXIT_FAILURE); + } break; case 'u': config.upgrade = true;