bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/2] fseeko: fix bug on glibc


From: Eric Blake
Subject: [PATCH 1/2] fseeko: fix bug on glibc
Date: Tue, 9 Aug 2011 15:52:53 -0600

Commit 1074f45959f had a bug on glibc that caused the unit test to
fail, but instead of figuring why the failure was happening, we
instead added a partial hack to avoid the problem in the scenario
covered by the testsuite.
https://lists.gnu.org/archive/html/bug-gnulib/2009-01/msg00171.html

But that hack doesn't cover all scenarios, and papers over the
real issue: if you fopen()/ftell()/fseek(,0,SEEK_END)/ftell(),
then the stream should be positioned at the same place as the
underlying fd, even though no I/O occurred, and without requiring
an fflush() in the middle.

* lib/fseeko.c (fseeko): Set stream offset to match fd offset.
Reported by John W. Eaton.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog    |    6 ++++++
 lib/fseeko.c |    1 +
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7824c84..0917f5e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-08-09  Eric Blake  <address@hidden>
+
+       fseeko: fix bug on glibc
+       * lib/fseeko.c (fseeko): Set stream offset to match fd offset.
+       Reported by John W. Eaton.
+
 2011-08-08  Bruno Haible  <address@hidden>

        unictype/base: Fix interoperability with preinstalled libunistring.
diff --git a/lib/fseeko.c b/lib/fseeko.c
index 1546f1b..80ca1e0 100644
--- a/lib/fseeko.c
+++ b/lib/fseeko.c
@@ -111,6 +111,7 @@ fseeko (FILE *fp, off_t offset, int whence)

 #if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, 
Linux libc5 */
       fp->_flags &= ~_IO_EOF_SEEN;
+      fp->_offset = pos;
 #elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, 
DragonFly, MacOS X, Cygwin */
 # if defined __CYGWIN__
       /* fp_->_offset is typed as an integer.  */
-- 
1.7.4.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]