mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 17:58:18 +03:00
LibC: Fix FILE::flush() passing bogus arguments to lseek()
This was a regression from the 64-bit off_t changes. When dropping buffered data after a flush, we would subtract the buffered amount from zero to get the seek offset. This didn't work right since the subtraction was done with a 32-bit size_t and we ended up with e.g (i64)0xfffffffc as the offset. Fixes #6003.
This commit is contained in:
parent
64d4921f35
commit
bf1ad16078
Notes:
sideshowbarker
2024-07-18 20:51:26 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/bf1ad160788
@ -175,12 +175,12 @@ bool FILE::flush()
|
||||
}
|
||||
if (m_mode & O_RDONLY) {
|
||||
// When open for reading, just drop the buffered data.
|
||||
size_t had_buffered = m_buffer.buffered_size();
|
||||
VERIFY(m_buffer.buffered_size() <= NumericLimits<off_t>::max());
|
||||
off_t had_buffered = m_buffer.buffered_size();
|
||||
m_buffer.drop();
|
||||
// Attempt to reset the underlying file position to what the user
|
||||
// expects.
|
||||
int rc = lseek(m_fd, -had_buffered, SEEK_CUR);
|
||||
if (rc < 0) {
|
||||
if (lseek(m_fd, -had_buffered, SEEK_CUR) < 0) {
|
||||
if (errno == ESPIPE) {
|
||||
// We can't set offset on this file; oh well, the user will just
|
||||
// have to cope.
|
||||
|
Loading…
Reference in New Issue
Block a user