aboutsummaryrefslogtreecommitdiff
path: root/elf/dblload.c
diff options
context:
space:
mode:
authorTulio Magno Quites Machado Filho <tuliom@redhat.com>2025-01-28 15:37:44 -0300
committerTulio Magno Quites Machado Filho <tuliom@redhat.com>2025-01-28 15:37:44 -0300
commit596a61cf6b51ce2d58b8ca4e1d1f4fdfe1440dbc (patch)
tree6e543a49b885e2dfc8de57c84e90137298ba6449 /elf/dblload.c
parent45c42b65c29422b773ac94771aa71165e245f8f8 (diff)
downloadglibc-596a61cf6b51ce2d58b8ca4e1d1f4fdfe1440dbc.zip
glibc-596a61cf6b51ce2d58b8ca4e1d1f4fdfe1440dbc.tar.gz
glibc-596a61cf6b51ce2d58b8ca4e1d1f4fdfe1440dbc.tar.bz2
libio: Start to return errors when flushing fwrite's buffer [BZ #29459]
When an error happens, fwrite is expected to return a value that is less than nmemb. If this error happens while flushing its internal buffer, fwrite is in a complex scenario: all the data might have been written to the buffer, indicating a successful copy, but the buffer is expected to be flushed and it was not. POSIX.1-2024 states the following about errors on fwrite: If an error occurs, the resulting value of the file-position indicator for the stream is unspecified. The fwrite() function shall return the number of elements successfully written, which may be less than nitems if a write error is encountered. With that in mind, this commit modifies _IO_new_file_write in order to return the total number of bytes written via the file pointer. It also modifies fwrite in order to use the new information and return the correct number of bytes written even when sputn returns EOF. Add 2 tests: 1. tst-fwrite-bz29459: This test is based on the reproducer attached to bug 29459. In order to work, it requires to pipe stdout to another process making it hard to reuse test-driver.c. This code is more specific to the issue reported. 2. tst-fwrite-pipe: Recreates the issue by creating a pipe that is shared with a child process. Reuses test-driver.c. Evaluates a more generic scenario. Co-authored-by: Florian Weimer <fweimer@redhat.com> Reviewed-by: DJ Delorie <dj@redhat.com>
Diffstat (limited to 'elf/dblload.c')
0 files changed, 0 insertions, 0 deletions