This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug stdio/21037] open_memstream and freopen


https://sourceware.org/bugzilla/show_bug.cgi?id=21037

--- Comment #1 from cvs-commit at gcc dot gnu.org <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  0b727ed4d605d9318cb0d323c88abb0d5a441a9b (commit)
      from  d0e91e8c4ef77997c940538eaa752799c9dda2d3 (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=0b727ed4d605d9318cb0d323c88abb0d5a441a9b

commit 0b727ed4d605d9318cb0d323c88abb0d5a441a9b
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Jul 13 16:43:24 2017 -0300

    libio: Flush stream at freopen (BZ#21037)

    As POSIX states [1] a freopen call should first flush the stream as if by a
    call fflush.  C99 (n1256) and C11 (n1570) only states the function should
    first close any file associated with the specific stream.  Although current
    implementation only follow C specification, current BSD and other libc
    implementation (musl) are in sync with POSIX and fflush the stream.

    This patch change freopen{64} to fflush the stream before actually
reopening
    it (or returning if the stream does not support reopen).  It also changes
the
    Linux implementation to avoid a dynamic allocation on 'fd_to_filename'.

    Checked on x86_64-linux-gnu.

        [BZ #21037]
        * libio/Makefile (tests): Add tst-memstream4 and tst-wmemstream4.
        * libio/freopen.c (freopen): Sync stream before reopen and adjust to
        new fd_to_filename interface.
        * libio/freopen64.c (freopen64): Likewise.
        * libio/tst-memstream.h: New file.
        * libio/tst-memstream4.c: Likewise.
        * libio/tst-wmemstream4.c: Likewise.
        * sysdeps/generic/fd_to_filename.h (fd_to_filename): Change signature.
        * sysdeps/unix/sysv/linux/fd_to_filename.h (fd_to_filename): Likewise
        and remove internal dynamic allocation.

    [1] http://pubs.opengroup.org/onlinepubs/9699919799/

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                                |   14 ++++++
 libio/Makefile                           |    4 +-
 libio/freopen.c                          |   29 +++++++------
 libio/freopen64.c                        |   26 +++++++-----
 libio/tst-memstream.h                    |   68 ++++++++++++++++++++++++++++++
 libio/tst-memstream4.c                   |   64 ++++++++++++++++++++++++++++
 libio/tst-wmemstream4.c                  |   20 +++++++++
 sysdeps/generic/fd_to_filename.h         |    4 +-
 sysdeps/unix/sysv/linux/fd_to_filename.h |   34 +++++----------
 9 files changed, 214 insertions(+), 49 deletions(-)
 create mode 100644 libio/tst-memstream.h
 create mode 100644 libio/tst-memstream4.c
 create mode 100644 libio/tst-wmemstream4.c

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]