Closed
Bug 16610
Opened 25 years ago
Closed 21 years ago
3 methods don't throw INDEX_SIZE_ERR
Categories
(Core :: DOM: Core & HTML, defect, P4)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
WONTFIX
mozilla1.6alpha
People
(Reporter: dbaron, Assigned: peterv)
References
Details
(Keywords: dom1, testcase, Whiteboard: http://www.fas.harvard.edu/~dbaron/dom/test/one-core-xml/exceptions)
Attachments
(2 files, 1 obsolete file)
6.18 KB,
patch
|
jst
:
superreview-
|
Details | Diff | Splinter Review |
1.85 KB,
patch
|
Details | Diff | Splinter Review |
DESCRIPTION: The methods insertData(), deleteData(), and replaceData() of the
Text interface don't throw INDEX_SIZE_ERR at all. (Note that they should throw
it only when outside of the range 0 <= n <= length, NOT 0 <= n < length!! I've
been through this before on the things that do throw INDEX_SIZE_ERR...)
STEPS TO REPRODUCE:
* Load http://www.fas.harvard.edu/~dbaron/dom/test/one-core-xml/exceptions
or http://www.fas.harvard.edu/~dbaron/dom/test/one-core-html/exceptions
* Hit "test exceptions"
ACTUAL RESULTS:
* All but the first 8 lines of the testing of the Text interface (which starts
a little more than halfway through) are red.
EXPECTED RESULTS:
* They should be green.
DOES NOT WORK CORRECTLY ON:
* Linux, viewer, 1999-10-15-11-M11
Reporter | ||
Comment 1•25 years ago
|
||
The problem I mentioned in the description (that you should avoid when fixing
this) was bug 9777.
Reporter | ||
Comment 2•25 years ago
|
||
Reporter | ||
Updated•25 years ago
|
Whiteboard: fix attached
Updated•25 years ago
|
Assignee: vidur → waqar
Comment 3•25 years ago
|
||
Reassigning to Waqar, since he's been in that code quite a lot recently.
Updated•25 years ago
|
Status: RESOLVED → REOPENED
Comment 5•25 years ago
|
||
This bug is still open as of 1999112809 Linux build.
Reopening bug.
Reporter | ||
Comment 6•25 years ago
|
||
Hmmm. It looks fine to me in Linux mozilla 1999-11-28-08-M12.
Comment 8•25 years ago
|
||
Marking VERIFIED FIXED on:
- Linux6 2000-03-07-09 Commercial build
- MacOS9 2000-03-07-08 Commercial build
- Win98 2000-03-07-09 Commercial build
Status: RESOLVED → VERIFIED
Comment 9•24 years ago
|
||
replaceData(offset,count,arg) does not throw exception when count is negative.
Visit http://www.mindspring.com/~bobclary/domtest2/tc.html using a recent build
of Mozilla, select the following test cases: tc_ccda501, tc_ccom501, tc_ctxt501
and submit.
To view a report click on a link in the left frame. Due to a scrollbar bug you
will need to click into the right frame and use your keyboard to navigate.
Reporter | ||
Comment 10•24 years ago
|
||
Reopening based on above comments. Perhaps it's because it's a PRUint32 rather
than PRInt32.
Status: VERIFIED → REOPENED
Resolution: FIXED → ---
Comment 11•24 years ago
|
||
dbaron is right.
153 void CharacterData::replaceData(Int32 aOffset, Int32 aCount,
154 const String& aSource)
155 {
156 nsCharacterData->ReplaceData(aOffset, aCount, aSource.getConstNSString());
157 }
158
But
407 nsresult
408 nsGenericDOMDataNode::ReplaceData(nsIContent *aOuterContent, PRUint32 aOffset,
409 PRUint32 aCount, const nsAReadableString& aData)
410 {
411 nsresult result = NS_OK;
412 413 // sanitize arguments 414 PRUint32 textLength = mText.GetLength();
415 if ((aOffset > textLength) || (aOffset < 0) || (aCount < 0)) {
416 return NS_ERROR_DOM_INDEX_SIZE_ERR;
417 }
418
Comment 13•24 years ago
|
||
The DOM spec defines the integer input arguments to replaceData() as "unigned
long" so passing in -1 is invalid and should be caught by the language compiler
(it you're using a language that is strongly typed) but in the case of JS we
fail to catch this problem. We simply do a JS_ValueToInt32() on the arguments
and we pass a PRUint32 typecasted to int32 so we loose the fact that the
argument is negative, in stead we get the argument as 0xffffffff and that's a
valid count as far as replaceData() goes...
If we wanto get this right we need to convert the JSVal to a signed quantity
first to check if it's negative or not and if it is then we need to throw an
exception (note, IMO the DOM exception INDEX_SIZE_ERR is not the correct
exception here since we never even get into DOM code before we realize that the
input is invalid, a JS specific exeption saying that the value is out of range
would be the correct exception to throw). If the value is not negative we need
to get it as a unsigned quantity and continue calling replaceData(). I don't
really wanna fix this now since the glue code where this fix would go will be
removed soon anyway so I'll leave this open for now, XPConnect should deal with
things like this in the future. Setting milestone to mozilla1.1 for now.
Status: NEW → ASSIGNED
OS: Linux → All
Hardware: PC → All
Target Milestone: M12 → mozilla1.1
Updated•24 years ago
|
Whiteboard: fix attached
Updated•24 years ago
|
Component: DOM Level 1 → DOM Core
Comment 16•23 years ago
|
||
An approach would be to create a signed wrapper for
nsGenericDOMNode::ReplaceData to complement the unsigned implementation:
Since you already have this:
nsresult
408 nsGenericDOMDataNode::ReplaceData(nsIContent *aOuterContent, PRUint32 aOffset,
409 PRUint32 aCount, const nsAReadableString& aData)
410 {
411 nsresult result = NS_OK;
412 413 // sanitize arguments 414 PRUint32 textLength = mText.GetLength();
415 if ((aOffset > textLength) || (aOffset < 0) || (aCount < 0)) {
416 return NS_ERROR_DOM_INDEX_SIZE_ERR;
417 }
....
You could add:
nsresult
nsGenericDOMDataNode::ReplaceData(nsIContent *aOuterContent, PRint32 aOffset,
PRint32 aCount, const nsAReadableString& aData)
{
nsresult result = NS_OK;
if((aOffset < 0) || (aCount < 0)) {
return NS_ERROR_DOM_INDEX_SIZE_ERR;
}
return ReplaceData(aOuterContent, (PRUint32) aOffset, (PRUint32) aCount, aData);
}
You could remove the spurious < 0's in the unsigned implementations. If code
has (hopefully safely) cast down to unsigned numbers, then they will bypass the
signed wrapper.
Comment 17•23 years ago
|
||
Method over loading requires API changes to frozen API's, and it's also
impossible to overload methods in XPIDL.
Updated•23 years ago
|
Keywords: testcase
Priority: P3 → P4
Whiteboard: http://www.fas.harvard.edu/~dbaron/dom/test/one-core-xml/exceptions
Comment 18•23 years ago
|
||
Does characterdata.substringdata(10, -9) fall in this catogery.
Comment 19•23 years ago
|
||
Yes.
Comment 20•23 years ago
|
||
bug 43164 also covers
characterdata.substringdata(10, -9)
Comment 21•23 years ago
|
||
The INDEX_SIZE_ERR expection is also not thrown for these two cases.
HTMLTableSectionElement.insertRow and HTMLTableSectionElement.deleteRow
Updated•22 years ago
|
Target Milestone: mozilla1.1alpha → ---
Comment 22•22 years ago
|
||
Mass-reassigning bugs to dom_bugs@netscape.com
Assignee: jst → dom_bugs
Status: ASSIGNED → NEW
Assignee | ||
Comment 23•21 years ago
|
||
*** Bug 43164 has been marked as a duplicate of this bug. ***
Assignee | ||
Comment 24•21 years ago
|
||
Taking.
Assignee: dom_bugs → peterv
Target Milestone: --- → mozilla1.6alpha
Assignee | ||
Comment 25•21 years ago
|
||
Attachment #2691 -
Attachment is obsolete: true
Assignee | ||
Updated•21 years ago
|
Status: NEW → ASSIGNED
Assignee | ||
Comment 26•21 years ago
|
||
Comment on attachment 131798 [details] [diff] [review]
v1
Let's see what jst thinks about this approach.
Attachment #131798 -
Flags: superreview?(jst)
Comment 27•21 years ago
|
||
Comment on attachment 131798 [details] [diff] [review]
v1
Hmm, I'd much rather see this done in XPConnect, where it IMO belongs. Putting
this anywhere else opens the door for errors in situations where JS passes a
negative value to a C++ function that then ends up calling this function.
So sr-, unless someone convinces me that this really doesn't belong in
XPConnect.
Attachment #131798 -
Flags: superreview?(jst) → superreview-
Assignee | ||
Comment 28•21 years ago
|
||
Assignee | ||
Comment 29•21 years ago
|
||
Attachment 131811 [details] [diff] fixes this in XPConnect, though I'm open to suggestions (I'm
no expert on how to do conversions in the JS engine). I would personally prefer
not putting this in XPConnect, if only because it would throw the wrong exception.
CC'ing some XPConnect and JS people. Do we want to enforce the signedness of
integer arguments when going from JS to native?
Comment 30•21 years ago
|
||
1. If we're going to do this much, shouldn't we go ahead and test both sides of
the valid range for all the types?
2. I wonder how much code currently works because of this "hole" and won't after
it's plugged.
Comment 31•21 years ago
|
||
I don't think we should be changing this post-mozilla-1.0. The risk of breaking
backwards compatibility is too great.
What other methods might want this change? Why shouldn't this change be done in
the DOM layer?
/be
Assignee | ||
Comment 32•21 years ago
|
||
Comment 21 lists two other DOM methods that might need this. I don't think we
want to impose this on methods outside the DOM. I think the DOM case is a bit
weird, in that the recommendation's idl specifies these arguments as unsigned
long, but then also specifies what needs to happen if negative arguments get
passed in. For other cases, I personally would expect the current
conversion-to-positive behaviour to happen.
I could add a better check that this isn't called through another C++ function
on the same object by checking the interface this gets called through and with
the methodindex (I think). Not sure we'd want that in non-debug builds though.
Assignee | ||
Comment 33•21 years ago
|
||
Jst, do you still oppose attachment 131798 [details] [diff] [review]?
Comment 34•21 years ago
|
||
I think I'd prefer that we either do this in the binding layer, or we don't do
it at all. I agree that it's way late to make a change like this in the binding
layer, unless we can limit such a change to DOM objects, which we could, but I
don't think that'll be very clean or low-impact, or worth the trouble, even.
Assignee | ||
Comment 35•21 years ago
|
||
Ok, then I guess this is a WONTFIX. Sad.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago → 21 years ago
Resolution: --- → WONTFIX
I think we should reopen this. Chaning this on the DOM side has effectively the same effect as the v2 patch since it'll only affect XPIDL interfaces, of which there are very few that content interacts with other than the DOM.
Component: DOM: Core → DOM: Core & HTML
QA Contact: stummala → general
Comment 37•16 years ago
|
||
Bug is still actual in FF3.
You need to log in
before you can comment on or make changes to this bug.
Description
•