Open Bug 1006141 Opened 10 years ago Updated 2 years ago

AndroidCameraInputStream::ReadSegments does not respect byte counts from 'writer'

Categories

(Core :: Networking, defect, P3)

All
Android
defect

Tracking

()

People

(Reporter: jimb, Unassigned)

Details

(Whiteboard: [necko-backlog])

AndroidCameraInputStream doesn't handle partial byte counts from aWriter when writing the header; and will double-write blocks of frame data if aWriter returns a partial count when writing frames.

I came across this issue doing an audit of ReadSegments implementations, so I don't know that this actually causes any problems in real life. ReadSegments definitely does not implement the behavior specified for nsIInputStream::ReadSegments, but if AndroidCameraInputStream is only ever used with aWriter functions that always accept the full count of bytes passed to them, then there's no observable bug.
 
In general, the nsWriteSegmentFun passed to nsIInputStream::ReadSegments may set *aWriteCount to fewer than the aCount bytes it was given, per spec:

https://hg.mozilla.org/mozilla-central/file/2897fb554990/xpcom/io/nsIInputStream.idl#l12

However, AndroidCameraInputStream::ReadSegments isn't prepared for its aWriter argument to do anything other than write the full count of bytes passed to it. If the call to aWriter dealing with the header returns a partial count, the code simply drops the rest of the header. If the call to aWriter writing a frame returns a partial count, the code attempts to rewrite the entire frame from scratch to the stream.
Whiteboard: [necko-backlog]
Bulk change to priority: https://bugzilla.mozilla.org/show_bug.cgi?id=1399258
Priority: -- → P1
Bulk change to priority: https://bugzilla.mozilla.org/show_bug.cgi?id=1399258
Priority: P1 → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.