summaryrefslogtreecommitdiff
path: root/grp
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-01-30 17:20:29 +0000
committerUlrich Drepper <drepper@redhat.com>1998-01-30 17:20:29 +0000
commit69032e82e9c0c26b104ee4a03a83afb3380aace8 (patch)
tree65b6f4a180522258e599ccb199bb787a27c9dffa /grp
parent6ecb7620e5eaffeac8b8ccd3617b0eba28b408cf (diff)
Correctly handle buffer overflow while reading line with fgets.
Diffstat (limited to 'grp')
-rw-r--r--grp/fgetgrent_r.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/grp/fgetgrent_r.c b/grp/fgetgrent_r.c
index 44298c5ba6..1a37e0477c 100644
--- a/grp/fgetgrent_r.c
+++ b/grp/fgetgrent_r.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -60,12 +60,18 @@ __fgetgrent_r (FILE *stream, struct group *resbuf, char *buffer, size_t buflen,
do
{
+ buffer[buflen] = '\xff';
p = fgets (buffer, buflen, stream);
- if (p == NULL)
+ if (p == NULL && feof (stream))
{
*result = NULL;
return errno;
}
+ if (p == NULL || buffer[buflen] != '\xff')
+ {
+ *result = NULL;
+ return errno = ERANGE;
+ }
/* Skip leading blanks. */
while (isspace (*p))