summary refs log tree commit diff
path: root/misc/getusershell.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2006-12-09 22:29:37 +0000
committerUlrich Drepper <drepper@redhat.com>2006-12-09 22:29:37 +0000
commit66f17705e46e88f8f01e66556fe62487aecdce29 (patch)
treeb679c1a0b36f8f136299066fa7700847710f5953 /misc/getusershell.c
parent60608028117600c2ca2c2ef8c122d56da253cc78 (diff)
downloadglibc-66f17705e46e88f8f01e66556fe62487aecdce29.tar.gz
glibc-66f17705e46e88f8f01e66556fe62487aecdce29.tar.xz
glibc-66f17705e46e88f8f01e66556fe62487aecdce29.zip
* sysdeps/unix/sysv/linux/rtld-lowlevel.h
	(__rtld_mrlock_initialize): Add missing closing parenthesis.
Diffstat (limited to 'misc/getusershell.c')
-rw-r--r--misc/getusershell.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/misc/getusershell.c b/misc/getusershell.c
index 255b579b1a..636da322f9 100644
--- a/misc/getusershell.c
+++ b/misc/getusershell.c
@@ -98,7 +98,7 @@ initshells()
 	register char **sp, *cp;
 	register FILE *fp;
 	struct stat64 statb;
-	int flen;
+	size_t flen;
 
 	free(shells);
 	shells = NULL;
@@ -114,9 +114,11 @@ initshells()
 		okshells[1] = _PATH_CSHELL;
 		return (char **) okshells;
 	}
-	if ((strings = malloc((u_int)statb.st_size + 1)) == NULL)
+	if (statb.st_size > ~(size_t)0 / sizeof (char *) * 3)
 		goto init_okshells;
-	shells = calloc((unsigned)statb.st_size / 3, sizeof (char *));
+	if ((strings = malloc(statb.st_size + 2)) == NULL)
+		goto init_okshells;
+	shells = malloc(statb.st_size / 3 * sizeof (char *));
 	if (shells == NULL) {
 		free(strings);
 		strings = NULL;
@@ -124,11 +126,11 @@ initshells()
 	}
 	sp = shells;
 	cp = strings;
-	flen = statb.st_size;
+	flen = statb.st_size + 2;
 	while (fgets_unlocked(cp, flen - (cp - strings), fp) != NULL) {
 		while (*cp != '#' && *cp != '/' && *cp != '\0')
 			cp++;
-		if (*cp == '#' || *cp == '\0')
+		if (*cp == '#' || *cp == '\0' || cp[1] == '\0')
 			continue;
 		*sp++ = cp;
 		while (!isspace(*cp) && *cp != '#' && *cp != '\0')