Closed Bug 18949 Opened 25 years ago Closed 25 years ago

file buffering in nsIFileStream ignores seeks.

Categories

(SeaMonkey :: UI Design, defect, P3)

All
Windows NT
defect

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: Bienvenu, Assigned: dougt)

Details

Local mail folders were getting corrupted because the buffering added to
nsIFileStream ignores seeks. So the sequence of calls need to corrupt a file is
as simple as this:

stream->write(buf)...
seek (somewhere else)
close

the output buffers will get written out at close time, at the location we've
seeked to, not the location we thought we were at when we did the write.

A simple fix for this is to make seek do a flush. I've changed my code to do a
flush after every write, but other clients could get bit in very painful ways.
Severity: normal → critical
I've marked this critical since it can corrupt files.
sounds like a regression.  At one point seek would flush buffers.  Blame does
not see though some code rearragement.  Adding people to cc list.  Warren,
Simon, do you think any of your changes could have cause this directly or
indirectly?
The only changes I made were to un-inline some methods in nsFileImpl, and not do
PR_Sync on read-only file close.
it is a simple fix.  We need to make seek() call flush().
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
thats what you said!!..  :-)  fixed.
QA Contact: don → sairuh
rubberstamp vrfy.
Status: RESOLVED → VERIFIED
Product: Core → Mozilla Application Suite
You need to log in before you can comment on or make changes to this bug.