Add checks for int parameters values
This commit is contained in:
parent
c3c7945ddf
commit
bfdb3b4161
14
gget.c
14
gget.c
|
@ -515,7 +515,12 @@ int main(int argc, char** argv)
|
||||||
while ((opt = getopt(argc, argv, "hn:l:o:u:qm:")) != -1) {
|
while ((opt = getopt(argc, argv, "hn:l:o:u:qm:")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'n':
|
case 'n':
|
||||||
nb_threads = atoi(optarg);
|
nb_threads = strtoul(optarg, &endptr, 0);
|
||||||
|
if (*endptr)
|
||||||
|
{
|
||||||
|
usage(argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
if (nb_threads == 0)
|
if (nb_threads == 0)
|
||||||
nb_threads = DEFAULT_NB_THREADS;
|
nb_threads = DEFAULT_NB_THREADS;
|
||||||
else if (nb_threads > MAX_NB_THREADS)
|
else if (nb_threads > MAX_NB_THREADS)
|
||||||
|
@ -525,7 +530,12 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
max_speed = atoi(optarg);
|
max_speed = strtoul(optarg, &endptr, 0);
|
||||||
|
if (*endptr)
|
||||||
|
{
|
||||||
|
usage(argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
if (strlen(optarg) > 1)
|
if (strlen(optarg) > 1)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user