From: Ulrich Drepper Date: Mon, 7 Jun 1999 20:17:36 +0000 (+0000) Subject: Update. X-Git-Tag: cvs/pre-glibc-2_1_3~796 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=db873f322bdefd03e68e7196277aee44fc021791;p=platform%2Fupstream%2Fglibc.git Update. 1999-06-07 Ulrich Drepper * grp/fgetgrent.c (fgetgrent): Remember position of stream before reading and reset in case the buffer was too small. * grp/fgetgrent_r.c (__fgetgrent_r): Set errno to ENOENT in case of EOF. --- diff --git a/ChangeLog b/ChangeLog index 47d51f77b8..b373d153c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +1999-06-07 Ulrich Drepper + + * grp/fgetgrent.c (fgetgrent): Remember position of stream before + reading and reset in case the buffer was too small. + + * grp/fgetgrent_r.c (__fgetgrent_r): Set errno to ENOENT in case + of EOF. + 1999-06-07 Andreas Jaeger * sysdeps/unix/sysv/linux/if_index.c: Use SIGIOCGIFINDEX and fix diff --git a/grp/fgetgrent.c b/grp/fgetgrent.c index 24fdcd86d9..ac8d093f05 100644 --- a/grp/fgetgrent.c +++ b/grp/fgetgrent.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1996, 1997, 1999 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 @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -32,9 +33,13 @@ fgetgrent (FILE *stream) static char *buffer; static size_t buffer_size; static struct group resbuf; + fpos_t pos; struct group *result; int save; + if (fgetpos (stream, &pos) != 0) + return NULL; + /* Get lock. */ __libc_lock_lock (lock); @@ -61,6 +66,13 @@ fgetgrent (FILE *stream) __set_errno (save); } buffer = new_buf; + + /* Reset the stream. */ + if (fsetpos (stream, &pos) != 0) + { + buffer = NULL; + break; + } } if (buffer == NULL) diff --git a/grp/fgetgrent_r.c b/grp/fgetgrent_r.c index 4abadfd569..0b1d782586 100644 --- a/grp/fgetgrent_r.c +++ b/grp/fgetgrent_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1996, 1997, 1998 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1996, 1997, 1998, 1999 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 @@ -74,13 +74,15 @@ __fgetgrent_r (FILE *stream, struct group *resbuf, char *buffer, size_t buflen, { funlockfile (stream); *result = NULL; + __set_errno (ENOENT); return errno; } if (p == NULL || buffer[buflen - 1] != '\xff') { funlockfile (stream); *result = NULL; - return errno = ERANGE; + __set_errno (ERANGE); + return errno; } /* Skip leading blanks. */