From c4be027b90040d04488d1e41bf311ec88e44c555 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 25 May 2015 17:27:14 +1000 Subject: [PATCH] test: fix coverity complaint about unbounded loop buffer tainted (from fgets()) so tighten the loop conditions a bit. Signed-off-by: Peter Hutterer --- test/litest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/litest.c b/test/litest.c index 7a4938da..040bfb4a 100644 --- a/test/litest.c +++ b/test/litest.c @@ -82,7 +82,7 @@ litest_backtrace_get_lineno(const char *executable, FILE* f; char buffer[PATH_MAX]; char *s; - int i; + unsigned int i; if (!cwd[0]) getcwd(cwd, sizeof(cwd)); @@ -119,7 +119,7 @@ litest_backtrace_get_lineno(const char *executable, /* now strip cwd from buffer */ s = buffer; i = 0; - while(cwd[i] == *s) { + while(i < strlen(cwd) && *s != '\0' && cwd[i] == *s) { *s = '\0'; s++; i++;