From 68b5204f29c1dde5ae03604807f715684a5cb594 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 18 Jan 2014 15:32:50 +0900 Subject: [PATCH] src: Set errno = 0 before calling strtol --- src/deflatehd.c | 2 ++ src/inflatehd.c | 1 + src/nghttp.cc | 1 + src/nghttpd.cc | 1 + 4 files changed, 5 insertions(+) diff --git a/src/deflatehd.c b/src/deflatehd.c index 4345592f..4ecb96fa 100644 --- a/src/deflatehd.c +++ b/src/deflatehd.c @@ -411,6 +411,7 @@ int main(int argc, char **argv) break; case 's': /* --table-size */ + errno = 0; config.table_size = strtoul(optarg, &end, 10); if(errno == ERANGE || *end != '\0') { fprintf(stderr, "-s: Bad option value\n"); @@ -419,6 +420,7 @@ int main(int argc, char **argv) break; case 'S': /* --deflate-table-size */ + errno = 0; config.deflate_table_size = strtoul(optarg, &end, 10); if(errno == ERANGE || *end != '\0') { fprintf(stderr, "-S: Bad option value\n"); diff --git a/src/inflatehd.c b/src/inflatehd.c index 9d868998..e8231e2d 100644 --- a/src/inflatehd.c +++ b/src/inflatehd.c @@ -269,6 +269,7 @@ int main(int argc, char **argv) exit(EXIT_SUCCESS); case 's': /* --table-size */ + errno = 0; config.table_size = strtoul(optarg, &end, 10); if(errno == ERANGE || *end != '\0') { fprintf(stderr, "-s: Bad option value\n"); diff --git a/src/nghttp.cc b/src/nghttp.cc index ea3439dd..cc8e9b04 100644 --- a/src/nghttp.cc +++ b/src/nghttp.cc @@ -1837,6 +1837,7 @@ int main(int argc, char **argv) config.multiply = strtoul(optarg, nullptr, 10); break; case 'c': + errno = 0; config.header_table_size = strtol(optarg, &end, 10); if(errno == ERANGE || *end != '\0') { std::cerr << "-c: Bad option value: " << optarg << std::endl; diff --git a/src/nghttpd.cc b/src/nghttpd.cc index 2da9d019..f9e0e251 100644 --- a/src/nghttpd.cc +++ b/src/nghttpd.cc @@ -167,6 +167,7 @@ int main(int argc, char **argv) config.verbose = true; break; case 'c': + errno = 0; config.header_table_size = strtol(optarg, &end, 10); if(errno == ERANGE || *end != '\0') { std::cerr << "-c: Bad option value: " << optarg << std::endl;