coverity/108274: tty-test.c: Insecure data handling (#8666)

This commit is contained in:
Justin M. Keyes 2018-07-01 14:48:30 +02:00 committed by GitHub
parent 40911e435e
commit 22d95e462e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -150,7 +150,12 @@ int main(int argc, char **argv)
}
if (argc > 1) {
int count = atoi(argv[1]);
errno = 0;
int count = (int)strtol(argv[1], NULL, 10);
if (errno != 0) {
abort();
}
count = (count < 0 || count > 99999) ? 0 : count;
for (int i = 0; i < count; i++) {
printf("line%d\n", i);
}