Open Bug 1425041 Opened 6 years ago Updated 2 years ago

handle serialization of partially read streams better

Categories

(Core :: IPC, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: bkelly, Unassigned)

References

Details

Currently we have a single infallible Serialize() method on nsIPCSerializableInputStream.  Code QIs to the interface and then assumes Serialize() is going to work.

This can clearly fall over, however, if you partially read a stream and then try to serialize.  For example, nsBufferedInputStream does not serialize any of its buffered data:

https://searchfox.org/mozilla-central/rev/9d920555ec81f1c9d4b7fa3b08e23eb88efb60e1/netwerk/base/nsBufferedStreams.cpp#558

It only sends the buffer size.  This means that calling Serialize() on one of these streams after you have triggered any reading of the base stream will happily drop data.

We should consider adding an nsIPCSerializableInputStream method like:

  virtual bool IsSerializable() = 0;

If this returns false then we can fall back to our IPCStream implementations.

Stream implementations could then indicate that they are not in a valid state for serialization.  This would also better support aggregate stream classes like nsMultiplexInputStream.
See Also: → 1424754
Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.