From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28542 invoked by alias); 4 Dec 2014 03:33:27 -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 Received: (qmail 28460 invoked by uid 55); 4 Dec 2014 03:33:20 -0000 From: "cvs-commit at gcc dot gnu.org" To: glibc-bugs@sourceware.org Subject: [Bug stdio/17653] ftell returns incorrect offset when a fd handle is activated due to stream read resulting in EOF Date: Thu, 04 Dec 2014 03:33:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: stdio X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: siddhesh at redhat dot com X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: security- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-12/txt/msg00037.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=17653 --- Comment #1 from cvs-commit at gcc dot gnu.org --- This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "GNU C Library master sources". The branch, master has been updated via 24b9788285effddba3d52f174d483583cf820d19 (commit) via fe8b4d98e9ac371238388469cb74011cb2120343 (commit) via 61b4f792e03facb456036b3f631d58d4f53b8075 (commit) via be349d7042de84c3c5157a5c1fbcad580aed33e1 (commit) from e3d6dba5dfe2e125b15ea1dd36c8dfa373bb4956 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=24b9788285effddba3d52f174d483583cf820d19 commit 24b9788285effddba3d52f174d483583cf820d19 Author: Siddhesh Poyarekar Date: Thu Dec 4 08:45:55 2014 +0530 Fix up function definition style Don't use K&R style for function definitions. https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=fe8b4d98e9ac371238388469cb74011cb2120343 commit fe8b4d98e9ac371238388469cb74011cb2120343 Author: Siddhesh Poyarekar Date: Thu Dec 4 08:13:28 2014 +0530 Reset cached offset when reading to end of stream (BZ #17653) POSIX allows applications to switch file handles when a read results in an end of file. Unset the cached offset at this point so that it is queried again. https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=61b4f792e03facb456036b3f631d58d4f53b8075 commit 61b4f792e03facb456036b3f631d58d4f53b8075 Author: Siddhesh Poyarekar Date: Thu Dec 4 08:11:07 2014 +0530 tst-ftell-active-handler: Open file with O_TRUNC for w modes The test case fails to truncate the file when a file is intended to be opened in w or w+ mode. Add O_TRUNC to fix this. The test still succeeds with this change. https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=be349d7042de84c3c5157a5c1fbcad580aed33e1 commit be349d7042de84c3c5157a5c1fbcad580aed33e1 Author: Siddhesh Poyarekar Date: Thu Dec 4 08:08:37 2014 +0530 ftell: seek to end only when there are unflushed bytes (BZ #17647) Currently we seek to end of file if there are unflushed writes or the stream is in write mode, to get the current offset for writing in append mode, which is the end of file. The latter case (i.e. stream is in write mode, but no unflushed writes) is unnecessary since it will only happen when the stream has just been flushed, in which case the recorded offset ought to be reliable. Removing that case lets ftell give the correct offset when it follows an ftruncate. The latter truncates the file, but does not change the file position, due to which it is permissible to call ftell without an intervening fseek call. Tested on x86_64 to verify that the added test case fails without the patch and succeeds with it, and that there are no additional regressions due to it. [BZ #17647] * libio/fileops.c (do_ftell): Seek only when there are unflushed writes. * libio/wfileops.c (do_ftell_wide): Likewise. * libio/tst-ftell-active-handler.c (do_ftruncate_test): New test case. (do_one_test): Call it. ----------------------------------------------------------------------- Summary of changes: ChangeLog | 30 ++++++++ NEWS | 2 +- libio/fileops.c | 134 +++++++++------------------------ libio/iofopen.c | 12 +-- libio/tst-ftell-active-handler.c | 152 +++++++++++++++++++++++++++++++++++--- libio/wfileops.c | 40 ++++------- 6 files changed, 225 insertions(+), 145 deletions(-) -- You are receiving this mail because: You are on the CC list for the bug.