Bug 316923 - Avoid overflow computing availableStackSize in KJS::RegExp::match
Summary: Avoid overflow computing availableStackSize in KJS::RegExp::match
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: kjs (show other bugs)
Version: 4.8.5
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-17 17:59 UTC by Andreas Schwab
Modified: 2013-04-02 19:01 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Avoid overflow when computing availableStackSize from stack limit (941 bytes, patch)
2013-03-17 17:59 UTC, Andreas Schwab
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Schwab 2013-03-17 17:59:01 UTC
Created attachment 78137 [details]
Avoid overflow when computing availableStackSize from stack limit

If the current stack limit is unlimited KJS::RegExp::availableStackSize is set to -1 (RLIM_INFINITY), which causes limits.match_limit_recursion being set to 0.  This results in the spurious error "RangeError: Resource exhaustion trying to perform regexp match."

$ ulimit -s unlimited
$ kjs -e '/a/.test("a")'
(eval) (line 0): RangeError: Resource exhaustion trying to perform regexp match.
Comment 1 Bernd Buschinski 2013-03-18 00:48:11 UTC
Thx for reporting,
but I posted a different solution on reviewboard
https://git.reviewboard.kde.org/r/109555/

which also makes 

$ ulimit -s 2147483649
$ kjs -e '/a/.test("a")'

work
Comment 2 Bernd Buschinski 2013-03-30 15:11:17 UTC
Git commit ffc8a6a316cacc8df6a91584653fe2c867a5d489 by Bernd Buschinski.
Committed on 29/03/2013 at 21:26.
Pushed by buschinski into branch 'master'.

kjs: Avoid overflow computing availableStackSize in KJS::RegExp::match

REVIEW:109555

M  +5    -0    kjs/regexp.cpp
M  +11   -0    kjs/regexp.h

http://commits.kde.org/kdelibs/ffc8a6a316cacc8df6a91584653fe2c867a5d489
Comment 3 Christophe Marin 2013-04-02 19:01:11 UTC
Bernd, Thanks for fixing this correctly. 

(and one more reason for submitting fixes upstream instead of submitting random quality patches to the opensuse packages)