librc: fix a read off-by-one bug

We should first check if we are within bounds and then read rather than
the opposite.

This makes valgrind happy.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
This commit is contained in:
Natanael Copa 2013-09-26 08:17:07 +00:00 committed by William Hubbs
parent 681a37e7bd
commit 03c67bcc27

View File

@ -193,7 +193,7 @@ file_regex(const char *file, const char *regex)
str += strlen(str) + 1;
/* len is the size of allocated buffer and we don't
want call regexec BUFSIZE times. find next str */
while (*str == '\0' && str < line + len)
while (str < line + len && *str == '\0')
str++;
} while (str < line + len);
}