test: fix coverity complaint about unbounded loop

buffer tainted (from fgets()) so tighten the loop conditions a bit.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2015-05-25 17:27:14 +10:00
parent d9f702918c
commit c4be027b90

View file

@ -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++;