From bfdb3b4161b6d14fc0d6c6a08f3d5dc4ccd55b20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Fri, 12 Aug 2016 18:11:54 +0200 Subject: [PATCH] Add checks for int parameters values --- gget.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gget.c b/gget.c index 43ce4ca..49fab52 100644 --- a/gget.c +++ b/gget.c @@ -515,7 +515,12 @@ int main(int argc, char** argv) while ((opt = getopt(argc, argv, "hn:l:o:u:qm:")) != -1) { switch (opt) { case 'n': - nb_threads = atoi(optarg); + nb_threads = strtoul(optarg, &endptr, 0); + if (*endptr) + { + usage(argv[0]); + return 1; + } if (nb_threads == 0) nb_threads = DEFAULT_NB_THREADS; else if (nb_threads > MAX_NB_THREADS) @@ -525,7 +530,12 @@ int main(int argc, char** argv) } break; case 'l': - max_speed = atoi(optarg); + max_speed = strtoul(optarg, &endptr, 0); + if (*endptr) + { + usage(argv[0]); + return 1; + } break; case 'm': if (strlen(optarg) > 1)