diff options
author | Ivan Zhakov <ivan@apache.org> | 2017-03-27 13:33:54 +0000 |
---|---|---|
committer | Ivan Zhakov <ivan@apache.org> | 2017-03-27 13:33:54 +0000 |
commit | 633f3d0ae58147397099f1147bd5e9e8cc141f2c (patch) | |
tree | 741743640d377749686d7a6d3a4c66f3b0e89ef8 /CHANGES | |
parent | 7b132ad30cd2f520aea81cd8f90343e484c30998 (diff) | |
download | apr-633f3d0ae58147397099f1147bd5e9e8cc141f2c.tar.gz |
Fix two issues with apr_file_trunc() for buffered files:
- The Win32 implementation incorrectly flushes the buffered writes _after_
truncating a file. Such files will have unexpected data written after
the position at which they should've been truncated. PR 51017.
(Under Unix, this issue has been fixed in r1044440)
- Both Win32 and Unix implementations incorrectly keep the data read into
a buffer after the file is truncated. Thus, reading from a file after
apr_file_trunc() can return invalid data from the previous file offset.
* file_io/win32/seek.c
(apr_file_trunc): Flush the write buffer or discard the read buffer
before truncating. Propely update the internal file offset (filePtr)
and the eof_hit marker.
* file_io/unix/seek.c
(apr_file_trunc): Discard the read buffer before truncating.
* test/testfile.c
(test_file_trunc): Extend the checks. Factor out part of this test...
(test_file_trunc_buffered_write): ...into this new test.
(test_file_trunc_buffered_write2, test_file_trunc_buffered_read): New tests.
(testfile): Run the new tests.
Patch by: Evgeny Kotkov <evgeny.kotkov {at} visualsvn.com>
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1788929 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'CHANGES')
-rw-r--r-- | CHANGES | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -1,6 +1,14 @@ -*- coding: utf-8 -*- Changes for APR 2.0.0 + *) apr_file_trunc: Truncating a buffered file could add unexpected + data after the truncate position. PR 51017. + [Evgeny Kotkov <evgeny.kotkov visualsvn.com>] + + *) apr_file_trunc: Fix an issue where reading from a buffered file + after truncate could return stale data from the buffer. + [Evgeny Kotkov <evgeny.kotkov visualsvn.com>] + *) apr_allocator, apr_pools: Add apr_allocator_page_size() and apr_allocator_min_order_set() to respectively get the (system's) page size in use and set the minimum allocation size for an allocator (expressed in |