1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-28 00:21:52 +03:00

Fix endless loop with invalid /etc/shells file.

This commit is contained in:
Ulrich Drepper
2010-02-03 06:23:31 -08:00
parent 1a36db1c12
commit caa6e77293
2 changed files with 8 additions and 2 deletions

View File

@ -116,7 +116,8 @@ initshells()
}
if (statb.st_size > ~(size_t)0 / sizeof (char *) * 3)
goto init_okshells;
if ((strings = malloc(statb.st_size + 2)) == NULL)
flen = statb.st_size + 3;
if ((strings = malloc(flen)) == NULL)
goto init_okshells;
shells = malloc(statb.st_size / 3 * sizeof (char *));
if (shells == NULL) {
@ -126,7 +127,6 @@ initshells()
}
sp = shells;
cp = strings;
flen = statb.st_size + 2;
while (fgets_unlocked(cp, flen - (cp - strings), fp) != NULL) {
while (*cp != '#' && *cp != '/' && *cp != '\0')
cp++;