diff options
author | Joseph Myers <josmyers@redhat.com> | 2024-09-05 20:08:10 +0000 |
---|---|---|
committer | Joseph Myers <josmyers@redhat.com> | 2024-09-05 20:08:10 +0000 |
commit | e44ca1c085b3bd41266c882ea1cb0fd436231635 (patch) | |
tree | 16652486b6f9ec07e8bf584ee95a2915b0dc3caf /libio/freopen64.c | |
parent | cc3e743fc09ee6fca45767629df9cbcbe1feba82 (diff) | |
download | glibc-e44ca1c085b3bd41266c882ea1cb0fd436231635.tar.gz glibc-e44ca1c085b3bd41266c882ea1cb0fd436231635.tar.xz glibc-e44ca1c085b3bd41266c882ea1cb0fd436231635.zip |
Fix freopen handling of ,ccs= (bug 23675)
As reported in bug 23675 and shown up in the recently added tests of different cases of freopen (relevant part of the test currently conditioned under #if 0 to avoid a failure resulting from this bug), freopen wrongly forces the stream to unoriented even when a mode with ,ccs= is specified, though such a mode is supposed to result in a wide-oriented stream. Move the clearing of _mode to before the actual reopening occurs, so that the main fopen implementation can leave a wide-oriented stream in the ,ccs= case. Tested for x86_64.
Diffstat (limited to 'libio/freopen64.c')
-rw-r--r-- | libio/freopen64.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/libio/freopen64.c b/libio/freopen64.c index 3a314aca5c..77c0dd3fdf 100644 --- a/libio/freopen64.c +++ b/libio/freopen64.c @@ -59,15 +59,13 @@ freopen64 (const char *filename, const char *mode, FILE *fp) fp->_flags2 &= ~(_IO_FLAGS2_MMAP | _IO_FLAGS2_NOTCANCEL | _IO_FLAGS2_CLOEXEC); + fp->_mode = 0; result = _IO_file_fopen (fp, gfilename, mode, 0); fp->_flags2 &= ~_IO_FLAGS2_NOCLOSE; if (result != NULL) result = __fopen_maybe_mmap (result); if (result != NULL) { - /* unbound stream orientation */ - result->_mode = 0; - if (fd != -1 && _IO_fileno (result) != fd) { /* At this point we have both file descriptors already allocated, |