nsBufferedOutputStream SetEOF() doesn't account for unwritten data in buffer
Categories
(Core :: Networking: File, defect, P2)
Tracking
()
People
(Reporter: benc, Unassigned, NeedInfo)
References
Details
(Whiteboard: [necko-triaged][necko-priority-next])
Attachments
(1 file)
|
2.41 KB,
patch
|
Details | Diff | Splinter Review |
Calling SetEOF() to truncate an nsBufferedOutputStream doesn't take into account unflushed data in the buffer.
It uses nsBufferedStream::SetEOF(), which just calls SetEOF() on the underlying stream:
https://searchfox.org/comm-central/rev/b56347bd5a63f051bdc994ed4051088b37df4c99/mozilla/netwerk/base/nsBufferedStreams.cpp#246
But if there's unwritten data in the buffer, it'll get written out at the next Flush().
This is confusing because - from the callers point of view - it was written out before the SetEOF() call, and thus should have been truncated.
| Reporter | ||
Comment 1•9 months ago
|
||
An xpcshell test to illustrate the issue.
| Reporter | ||
Comment 2•9 months ago
|
||
It needs a buffer-aware nsBufferedOutputStream::SetEOF(). But just calling Flush() before the underlying-stream SetEOF() isn't enough. The Flush() changes the position within the file, so the SetEOF() will occur at an unexpected position (unexpected to the caller, anyway).
Updated•8 months ago
|
Description
•