Closed Bug 303376 Opened 20 years ago Closed 20 years ago

[FIX]loadSubscript failed with async protocol (http) which uses NS_ImplementChannelOpen in the Open and js files bigger than 4096 bytes

Categories

(Core :: XPConnect, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9alpha1

People

(Reporter: jpx.dumont, Assigned: bzbarsky)

Details

Attachments

(1 file)

User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 1.0.3705) Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b2) Gecko/20050707 the catched error returned is #define LOAD_ERROR_READUNDERFLOW "File Read Error (underflow.)" cf file mozilla/xpconnect/loader/mozJSSubScriptLoader.cpp:298 rv = chan->Open (getter_AddRefs(instream)); if (NS_FAILED(rv)) { errmsg = JS_NewStringCopyZ (cx, LOAD_ERROR_NOSTREAM); goto return_exception; } rv = chan->GetContentLength (&len); if (NS_FAILED(rv) || len == -1) { errmsg = JS_NewStringCopyZ (cx, LOAD_ERROR_NOCONTENT); goto return_exception; } buf = new char[len + 1]; if (!buf) return NS_ERROR_OUT_OF_MEMORY; rv = instream->Read (buf, len, &readcount); if (NS_FAILED(rv)) { errmsg = JS_NewStringCopyZ (cx, LOAD_ERROR_BADREAD); goto return_exception; } the problem is that this code compares the chan->GetContentLength (actually more than 4096) with the readcount of the instream that is only 4096 at this time I notice that the bug is for asynchronous protocol wich use NS_ImplementChannelOpen(this, ...) in their Synchronous Open Channel funtion to glue to their OpenAsync... So perhaps the bug comes from NS_ImplementChannelOpen implementatation Best Regards, Reproducible: Always
sorry, but I ommit the last fragment of code wich return the error ;-) if (NS_STATIC_CAST(PRUint32, len) != readcount) { errmsg = JS_NewStringCopyZ (cx, LOAD_ERROR_READUNDERFLOW); goto return_exception; }
That looks like a bug in the subscript loader -- nothing guarantees that all the data is available immediately.
Assignee: general → dbradley
Status: UNCONFIRMED → NEW
Component: General → XPConnect
Ever confirmed: true
Product: Mozilla Application Suite → Core
QA Contact: general → pschwartau
Version: unspecified → Trunk
Attachment #203093 - Flags: superreview?(jst)
Attachment #203093 - Flags: review?(darin)
Summary: loadSubscript failed with async protocol (http) wich use NS_ImplementChannelOpen in the Open and js files bigger than 4096 bytes → loadSubscript failed with async protocol (http) which uses NS_ImplementChannelOpen in the Open and js files bigger than 4096 bytes
Comment on attachment 203093 [details] [diff] [review] I believe this is the right thing here.... lastReadCount declaration wants to be aligned with its peers ;) r=darin
Attachment #203093 - Flags: review?(darin) → review+
Comment on attachment 203093 [details] [diff] [review] I believe this is the right thing here.... sr=jst
Attachment #203093 - Flags: superreview?(jst) → superreview+
Assignee: dbradley → bzbarsky
Summary: loadSubscript failed with async protocol (http) which uses NS_ImplementChannelOpen in the Open and js files bigger than 4096 bytes → [FIX]loadSubscript failed with async protocol (http) which uses NS_ImplementChannelOpen in the Open and js files bigger than 4096 bytes
Fixed.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9alpha
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: