about summary refs log tree commit diff
path: root/libio/Makefile
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@redhat.com>2014-02-05 12:49:00 +0530
committerSiddhesh Poyarekar <siddhesh@redhat.com>2014-02-05 12:49:00 +0530
commitdf675f9933c5d5461cea9224ed43beddef1a7b3a (patch)
tree2a8dea7fe4b18c231b834b2c87356cb16cfeb07d /libio/Makefile
parent68159946307adfc95a6e99d1c4af5c3de0c030f9 (diff)
downloadglibc-df675f9933c5d5461cea9224ed43beddef1a7b3a.tar.gz
glibc-df675f9933c5d5461cea9224ed43beddef1a7b3a.tar.xz
glibc-df675f9933c5d5461cea9224ed43beddef1a7b3a.zip
Fix infinite loop in ftell when writing wide char data (BZ #16398)
ftell tries to avoid flushing the buffer when it is in write mode by
converting the wide char data and placing it into the binary buffer.
If the output buffer space is full and there is data to write, the
code reverts to flushing the buffer.  This breaks when there is space
in the buffer but it is not enough to convert the next character in
the wide data buffer, due to which __codecvt_do_out returns a
__codecvt_partial status.  In this case, ftell keeps running in an
infinite loop.

The fix here is to detect the __codecvt_partial status in addition to
checking if the buffer is full.  I have also added a test case that
demonstrates the infinite loop.
Diffstat (limited to 'libio/Makefile')
-rw-r--r--libio/Makefile2
1 files changed, 1 insertions, 1 deletions
diff --git a/libio/Makefile b/libio/Makefile
index 05432f4e6b..747a779951 100644
--- a/libio/Makefile
+++ b/libio/Makefile
@@ -60,7 +60,7 @@ tests = tst_swprintf tst_wprintf tst_swscanf tst_wscanf tst_getwc tst_putwc   \
 	tst-wmemstream1 tst-wmemstream2 \
 	bug-memstream1 bug-wmemstream1 \
 	tst-setvbuf1 tst-popen1 tst-fgetwc bug-wsetpos tst-fseek \
-	tst-fwrite-error
+	tst-fwrite-error tst-ftell-partial-wide
 ifeq (yes,$(build-shared))
 # Add test-fopenloc only if shared library is enabled since it depends on
 # shared localedata objects.