From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21794 invoked by alias); 27 Jul 2011 17:34:44 -0000 Received: (qmail 21674 invoked by uid 22791); 27 Jul 2011 17:34:41 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO sourceware.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 27 Jul 2011 17:34:26 +0000 From: "eblake at redhat dot com" To: glibc-bugs@sources.redhat.com Subject: [Bug libc/12724] fclose violates POSIX 2008 on seekable input streams X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: eblake at redhat dot com X-Bugzilla-Status: REOPENED X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: drepper.fsp at gmail dot com X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Status Resolution Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Wed, 27 Jul 2011 17:34:00 -0000 Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org X-SW-Source: 2011-07/txt/msg00120.txt.bz2 http://sourceware.org/bugzilla/show_bug.cgi?id=12724 Eric Blake changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|FIXED | --- Comment #2 from Eric Blake 2011-07-27 17:34:22 UTC --- glibc 2.14 still has issues. Per the latest wording: http://austingroupbugs.net/view.php?id=87#c838 At page 805 line 26801 section fclose, change: the file offset of the underlying open file description shall be adjusted so that the next operation on the open file description deals with the byte after the last one read from or written to the stream being closed. to: the file offset of the underlying open file description shall be set to the file position of the stream. fclose() _must_ reposition the underlying fd, even if there was no last byte read. Therefore, this program, which passes on Solaris, shows that glibc is still buggy: #include #include #include #include #include #include #include #define NAME "test-fclose.t" int main (void) { const char buf[] = "hello world"; int fd; int fd2; FILE *f; /* Prepare a seekable file. */ fd = open (NAME, O_RDWR | O_CREAT | O_TRUNC, 0600); assert (0 <= fd); assert (write (fd, buf, sizeof buf) == sizeof buf); assert (lseek (fd, 1, SEEK_SET) == 1); /* Create an output stream visiting the file; when it is closed, all other file descriptors visiting the file must see the new file position. */ fd2 = dup (fd); assert (0 <= fd2); f = fdopen (fd2, "w"); assert (f); assert(lseek(fd, 4, SEEK_SET) == 4); assert (fclose (f) == 0); errno = 0; assert (lseek (fd2, 0, SEEK_CUR) == -1); assert (errno == EBADF); assert (lseek (fd, 0, SEEK_CUR) == 4); /* Likewise for an input stream. */ fd2 = dup (fd); assert (0 <= fd2); f = fdopen (fd2, "r"); assert (f); assert(lseek(fd, 4, SEEK_SET) == 4); assert (fclose (f) == 0); errno = 0; assert (lseek (fd2, 0, SEEK_CUR) == -1); assert (errno == EBADF); assert (lseek (fd, 0, SEEK_CUR) == 4); /* Clean up. */ assert (remove (NAME) == 0); return 0; } -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.