Add checks for int parameters values

This commit is contained in:
Grégory Soutadé 2016-08-12 18:11:54 +02:00
parent c3c7945ddf
commit bfdb3b4161

14
gget.c
View File

@ -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)