Skip to content

Commit

Permalink
Coverity: fix Call to function atoi with tainted argument
Browse files Browse the repository at this point in the history
by using a different function that does better errror handling.

Signed-off-by: Robin Getz <[email protected]>
  • Loading branch information
rgetz committed Apr 8, 2020
1 parent 23ab5d8 commit e12120a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/iio_stresstest.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,15 +385,18 @@ int main(int argc, char **argv)
break;
case 'b':
info.arg_index += 2;
info.buffer_size = atoi(info.argv[info.arg_index]);
info.buffer_size = strtol(info.argv[info.arg_index], NULL, 10);
/* Max 4M */
if (info.buffer_size > (1024 * 1024 * 4))
info.buffer_size = 1024 * 1024 * 4;
break;
case 't':
info.arg_index +=2;
info.timeout = 1000 * atoi(info.argv[info.arg_index]);
info.timeout = 1000 * strtol(info.argv[info.arg_index], NULL, 10);
break;
case 'T':
info.arg_index +=2;
info.num_threads = atoi(info.argv[info.arg_index]);
info.num_threads = strtol(info.argv[info.arg_index], NULL, 10);
break;
case 'v':
if (!info.verbose)
Expand Down

0 comments on commit e12120a

Please sign in to comment.