Closed
Bug 294195
Opened 20 years ago
Closed 19 years ago
Special regular expression (regexp) crashes browser
Categories
(Core :: JavaScript Engine, defect, P1)
Tracking
()
VERIFIED
FIXED
mozilla1.8beta3
People
(Reporter: ebraun, Assigned: mrbkap)
References
()
Details
(Keywords: crash, js1.5, testcase)
Attachments
(2 files, 3 obsolete files)
282 bytes,
text/html
|
Details | |
3.88 KB,
patch
|
brendan
:
review+
brendan
:
approval1.8b3+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4
Using substr() method on string containing references to elements matched by
regular expression crashes Firefox.
Reproducible: Always
Steps to Reproduce:
1. Call replace() method on a string in JS script in a similar way as shown on
test page
Actual Results:
Browser crashes
Expected Results:
Definitely not crash.
Comment 1•20 years ago
|
||
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8b2) Gecko/20050514
Firefox/1.0+ ID:2005051410
Crashes for me.
TalkBackIDs:
- TB5834667X [@ js_ValidContextPointer]
- TB5834771X [@ MSVCRT.DLL]
Comment 2•20 years ago
|
||
Reporter | ||
Updated•20 years ago
|
Summary: Special regular regular expression crashes browser → Special regular expression crashes browser
Comment 3•20 years ago
|
||
Some more talkbackids
- TB5834926X [@ nsPropertyTable::DeleteAllPropertiesFor]
- TB5834989Q [@ MSVCRT.DLL]
- TB5835029Z [@ ntdll.dll]
Comment 4•20 years ago
|
||
The even shorter testcase
"".replace(/()/, "$1".slice(0,1))
generates an assertion in the debug shell:
Assertion failure: nbytes != 0, at jsapi.c:1494
Updated•20 years ago
|
Comment 5•20 years ago
|
||
Checking in regress-294195-01.js;
/cvsroot/mozilla/js/tests/js1_5/Regress/regress-294195-01.js,v <--
regress-294195-01.js
initial revision: 1.1
done
RCS file: /cvsroot/mozilla/js/tests/js1_5/Regress/regress-294195-02.js,v
done
Checking in regress-294195-02.js;
/cvsroot/mozilla/js/tests/js1_5/Regress/regress-294195-02.js,v <--
regress-294195-02.js
initial revision: 1.1
Flags: testcase+
Comment 6•20 years ago
|
||
AFAICT the problem is that interpret_dollar() in js/src/jsstr.c depends on
JSSTRING_CHARS(repstr) ending with a NUL char. This seems not to true if repstr
is a dependent string (like with string.slice()).
In the testcase jschar *dp in interpret_dollar() points to the last (only)
character in repstr ("$"). interpret_dollar() will then happily look at the next
character ("1") and interpret the "$" depending on that next character although
that character does not belong to repstr.
Comment 7•20 years ago
|
||
Yes, thanks -- will fix ASAP.
/be
Assignee: general → brendan
Flags: blocking1.8b2+
Keywords: js1.5
Priority: -- → P1
Target Milestone: --- → mozilla1.8beta2
Assignee | ||
Comment 8•20 years ago
|
||
Apologies for any stylistic faux pas in advance. This makes interpret_dollar
not assume null-termination.
Assignee | ||
Updated•20 years ago
|
Assignee | ||
Comment 9•19 years ago
|
||
This just makes things a bit more C-like.
Attachment #184021 -
Attachment is obsolete: true
Attachment #184519 -
Flags: review?(brendan)
Assignee | ||
Updated•19 years ago
|
Attachment #184021 -
Flags: review?(brendan)
Comment 10•19 years ago
|
||
(In reply to comment #9)
>+ while (++cp != ep && JS7_ISDEC(dc = *ep)) {
That should probably be *cp instead of *ep.
Assignee | ||
Comment 11•19 years ago
|
||
Yikes! Thanks for pointing that out.
Attachment #184519 -
Attachment is obsolete: true
Attachment #184537 -
Flags: review?(brendan)
Attachment #184519 -
Flags: review?(brendan)
Comment 12•19 years ago
|
||
Hi,
Can someone please check the patcgh so we can get shipped out?
This is taking too long.
Comment 13•19 years ago
|
||
bryanwellander@socal.rr.com: no.
we have a process.
the first step is reporting the bug (done).
the second step is analyzing the bug (done).
the third step is writing and posting a correct a patch (maybe done).
the fourth step is asking for and receiving a positive review (not done!).
after all reviews are gathered (not done), if the tree is frozen (it is), then
you need to get approval (not done).
lastly, someone with cvs access to the partition needs to commit it (clearly not
done), i'm not committing a patch that doesn't have the necessary reviews and
approvals, it's bad for the safety of my cvs account.
patience is a virtue, please practice it.
Updated•19 years ago
|
Flags: blocking1.8b3+
Flags: blocking1.8b2-
Flags: blocking1.8b2+
Comment 14•19 years ago
|
||
*** Bug 295734 has been marked as a duplicate of this bug. ***
Comment 15•19 years ago
|
||
Adding "regexp" to summary for easier searching
Summary: Special regular expression crashes browser → Special regular expression (regexp) crashes browser
Comment 16•19 years ago
|
||
Comment on attachment 184537 [details] [diff] [review]
patch v3
>@@ -1306,23 +1311,29 @@ interpret_dollar(JSContext *cx, jschar *
> return NULL;
>
> /* Check for overflow to avoid gobbling arbitrary decimal digits. */
> num = 0;
> cp = dp;
>- while ((dc = *++cp) != 0 && JS7_ISDEC(dc)) {
>+ while (++cp != ep && JS7_ISDEC(dc = *cp)) {
Robustness nit: I prefer < rather than !=, in case by some off-by-one or
insane-caller bug cp > ep.
>+
>+ /*
>+ * Note: cp cannot be greater than ep because of the dp + 1 == ep
>+ * check above.
>+ */
JS_ASSERT? Beats a comment every time. Could comment and assert; often the
assertion speaks for itself.
> cp = dp + 2;
>- dc = *cp;
>- if ((dc != 0) && JS7_ISDEC(dc)) {
>+ dc = (cp == ep) ? 0 : *cp;
>+
>+ if (dc != 0 && JS7_ISDEC(dc)) {
This reintroduces a NUL sensitivity that may not matter, but it seems better
and clearer to me to do:
if (cp < ep && (dc = *cp, JS7_ISDEC(dc))) {
Note righteous nested comma operator usage.
One more patch and I'll r+a=.
/be
Assignee | ||
Comment 17•19 years ago
|
||
This fixes up all of the review comments. I did away with the comment and the
assert by making the code not rely on the comment anymore (changing != to <
everywhere).
Assignee | ||
Updated•19 years ago
|
Attachment #184537 -
Attachment is obsolete: true
Attachment #185586 -
Flags: review?(brendan)
Comment 18•19 years ago
|
||
Comment on attachment 185586 [details] [diff] [review]
patch v4
r+a=me, thanks for fixing this.
/be
Attachment #185586 -
Flags: review?(brendan)
Attachment #185586 -
Flags: review+
Attachment #185586 -
Flags: approval1.8b3+
Assignee | ||
Updated•19 years ago
|
Attachment #184537 -
Flags: review?(brendan)
Assignee | ||
Comment 19•19 years ago
|
||
Fix checked in.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Target Milestone: mozilla1.8beta2 → mozilla1.8beta3
You need to log in
before you can comment on or make changes to this bug.
Description
•