From 22d95e462ec32e1b6c28b310e80c9c001edc0fe1 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 1 Jul 2018 14:48:30 +0200 Subject: [PATCH] coverity/108274: tty-test.c: Insecure data handling (#8666) --- test/functional/fixtures/tty-test.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/functional/fixtures/tty-test.c b/test/functional/fixtures/tty-test.c index 4f0858acdb..5f1f5cb91c 100644 --- a/test/functional/fixtures/tty-test.c +++ b/test/functional/fixtures/tty-test.c @@ -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); }