Open
Bug 347660
Opened 20 years ago
Updated 2 years ago
nsBufferedOutputStream::WriteSegments doesn't handle the reader returning zero
Categories
(Core :: Networking, defect, P5)
Core
Networking
Tracking
()
NEW
People
(Reporter: Biesinger, Unassigned)
References
()
Details
(Whiteboard: [necko-backlog])
Per http://lxr.mozilla.org/seamonkey/source/xpcom/io/nsIOutputStream.idl#60, the reader for writeSegments is allowed to return success and zero bytes. But, the buffered output stream does not handle that, it looks like it would go into an infinite loop in that case.
This is a quite relevant case since when used via writeFrom, this would hang at EOF (when the input stream would return zero).
Updated•10 years ago
|
Whiteboard: [necko-backlog]
Updated•10 years ago
|
Severity: critical → normal
Comment 1•9 years ago
|
||
Bulk change to priority: https://bugzilla.mozilla.org/show_bug.cgi?id=1399258
Priority: -- → P1
Comment 2•9 years ago
|
||
Bulk change to priority: https://bugzilla.mozilla.org/show_bug.cgi?id=1399258
Priority: P1 → P3
Comment 3•5 years ago
|
||
Bulk-downgrade of unassigned, untouched DOM/Storage bug's priority.
If you have reason to believe, this is wrong, please write a comment and ni :jstutte.
Severity: normal → S4
Priority: P3 → P5
Comment 4•2 years ago
|
||
I think this bug may still be valid, but not sure how much of an issue it really is in practice.
nsBufferedOutputStream::WriteSegments(nsReadSegmentFun reader, void* closure,
uint32_t count, uint32_t* _retval) {
*_retval = 0;
nsresult rv;
RecursiveMutexAutoLock lock(mBufferMutex);
while (count > 0) {
uint32_t left = std::min(count, mBufferSize - mCursor);
if (left == 0) {
rv = Flush();
if (NS_FAILED(rv)) {
return (*_retval > 0) ? NS_OK : rv;
}
continue;
}
uint32_t read = 0;
rv = reader(this, closure, mBuffer + mCursor, *_retval, left, &read);
if (NS_FAILED(rv)) { // If we have read some data, return ok
return (*_retval > 0) ? NS_OK : rv;
}
mCursor += read;
*_retval += read;
count -= read;
mFillPoint = std::max(mFillPoint, mCursor);
}
return NS_OK;
You need to log in
before you can comment on or make changes to this bug.
Description
•