Closed
Bug 135292
Opened 22 years ago
Closed 22 years ago
unsigned int being compared to -1
Categories
(Core Graveyard :: Plug-ins, defect, P3)
Core Graveyard
Plug-ins
Tracking
(Not tracked)
VERIFIED
FIXED
mozilla1.2beta
People
(Reporter: anthonyd, Assigned: anthonyd)
Details
(Whiteboard: [PL2:NA][patch])
Attachments
(1 file, 4 obsolete files)
1.44 KB,
text/plain
|
srgchrpv
:
review+
darin.moz
:
superreview+
|
Details |
actual code in question: ns4xPluginInstance.cpp, line 252 if (mNPStream.end == -1) mNPStream.end = 0; getting set to -1 in nsPluginHostImpl.cpp, line 2103. Fix or not? seems like we should, but I'm cold and scared. anthonyd
Comment 2•22 years ago
|
||
Tony, did you check the test cases from bug 52963, bug 52965 ? it's about java servlet connectivity through nsIPluginManager::GetURL/PostURL are there any reasons for that code? + // it's possible for the server to not send a Content-Length. We should + // still work in this case. + if (NS_FAILED(rv)) { + mPluginStreamInfo->SetLength(-1);
Comment 3•22 years ago
|
||
BTW: is there a posibility to get -1 from channel ? rv = channel->GetContentLength(&length); // it's possible for the server to not send a Content-Length. We should // still work in this case. if (NS_FAILED(rv)) { mPluginStreamInfo->SetLength(-1); } else { mPluginStreamInfo->SetLength(length); }
Its not so much about whether there is a reason for the code as it is about whether the code is correct. In the patch I attached, mNPStream.end (which is an unsigned int32) get assinged a -1 with the following block: nsPluginHostImpl.cpp mPluginStreamInfo->SetLength(-1); at some point later in the code, it is compared to -1 and set to zero if true: ns4xPluginInstance.cpp if (mNPStream.end == -1) mNPStream.end = 0; That variable is only set to -1 (really just FFFFF....) in one place, so after talking with peterl, the safe thing seemed to be to just go ahead and assign it to zero, since that seemed to be the purpose anyway of the code. It appeared to be just blind luck that the code was working in the first place, if that had been an unsigned short for instance, it would have failed. As to the testcases you mention, I will rebuild and test them, but peterl would be a better choice to ask about further ramifications of this small change. anthonyd
Comment 5•22 years ago
|
||
I'm just worried that someone may be expecting this -1 (FFFFFF) behavior.
Updated•22 years ago
|
Whiteboard: [patch] → [PL2:NA][patch]
need r's and sr's for this patch.
Whiteboard: [PL2:NA][patch] → [PL2:NA][patch][need r=, sr=]
Comment 10•22 years ago
|
||
Comment on attachment 78462 [details] [diff] [review] patch to fix the bug The code seems to be logically equivalent to what it was. r=av. Maybe it would be nicer to write it in one line: mPluginStreamInfo->SetLength(NS_SUCCEEDED(rv) ? length : 0); and make sure that testcases from all related bugs still work.
Attachment #78462 -
Flags: review+
Comment 11•22 years ago
|
||
Comment on attachment 78462 [details] [diff] [review] patch to fix the bug Serge just pointed out... We probably don't want commented out source lines dangling in the code, please make sure you remove them before you check in. Or better, attach a new patch.
Comment 12•22 years ago
|
||
I wouldn't remove this due to next comment // if we don't know the end of the stream, use 0 instead of -1. bug 59571 - if (mNPStream.end == -1) + if ((int)mNPStream.end == -1)
Comment 13•22 years ago
|
||
Comment on attachment 94718 [details] [diff] [review] alt patch Serge, but in the original patch, we already set it to null if we don't know the length.
Comment 14•22 years ago
|
||
all right after conversation with av we decided it safe now to remove if (mNPStream.end == -1) from ns4xPluginStreamListener::OnStartBinding
Attachment #94718 -
Attachment is obsolete: true
Comment 15•22 years ago
|
||
oops, wrong attachment:(
Comment 17•22 years ago
|
||
Comment on attachment 94724 [details] [diff] [review] alt v3 r=av
Attachment #94724 -
Flags: review+
Assignee | ||
Comment 18•22 years ago
|
||
I don't have a problem with the new patch, but who do I get a sr from?
Whiteboard: [PL2:NA][patch][need r=, sr=] → [PL2:NA][patch][need sr]
Comment 19•22 years ago
|
||
Comment on attachment 94724 [details] [diff] [review] alt v3 >Index: nsPluginHostImpl.cpp >+ PRInt32 length = 0; >+ channel->GetContentLength(&length); >+ mPluginStreamInfo->SetLength(length); you must check the return value of GetContentLength. it might fail, and upon failing it might set length to some arbitrary value that isn't at all consistent with the concept of content length.
Attachment #94724 -
Flags: needs-work+
Comment 20•22 years ago
|
||
well, I thought idl out param suppose to be unattached or set to 0 on failure. but it looks like there is no such requirements for out params:( lets use av's patch from comment #10 PRInt32 length; rv = channel->GetContentLength(&length) mPluginStreamInfo->SetLength(NS_SUCCEEDED(rv) ? length : 0);
Assignee | ||
Comment 21•22 years ago
|
||
Though it probably doesn't matter for this particular case, I really don't like the trinary argument because it is harder to debug (putting breakpoints). There is also no real point because any decent compiler will make sure that a trinary is equivalent to a if/else block. Anyway, whichever patch you want, just let me know. ADavis
Comment 22•22 years ago
|
||
please attach the patch you like.
Assignee | ||
Comment 23•22 years ago
|
||
I think the original patch was the simplest and most straight forward (other than the commented out lines of code, which I should have just deleted). I will go ahead and reattach the patch WITHOUT the commented out lines of code. But is there a technical error with the original patch? Thanks, ADavis
Comment 24•22 years ago
|
||
Comment on attachment 78462 [details] [diff] [review] patch to fix the bug the patch looks good, except the comments >+ //if (mNPStream.end == -1) >+ // mNPStream.end = 0; // see bug # 135292 >... >+// mPluginStreamInfo->SetLength(-1); >+ mPluginStreamInfo->SetLength(0);// see bug # 135292
Attachment #78462 -
Flags: needs-work+
Assignee | ||
Comment 25•22 years ago
|
||
this is the simple patch with the comments removed. just need the r= and sr= to get this finsihed. thanks all.
Attachment #78462 -
Attachment is obsolete: true
Attachment #94724 -
Attachment is obsolete: true
Comment 26•22 years ago
|
||
Comment on attachment 95470 [details]
new version of original patch
r=serge
Attachment #95470 -
Flags: review+
Comment 27•22 years ago
|
||
Comment on attachment 95470 [details]
new version of original patch
sr=darin
Attachment #95470 -
Flags: superreview+
Assignee | ||
Comment 28•22 years ago
|
||
got everything I need, will check in ASAP. thanks everyone. anthonyd
Whiteboard: [PL2:NA][patch][need sr] → [PL2:NA][patch]
Assignee | ||
Comment 29•22 years ago
|
||
checked in to trunk.
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Updated•2 years ago
|
Product: Core → Core Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•