Bug 316923

Summary: Avoid overflow computing availableStackSize in KJS::RegExp::match
Product: [Applications] konqueror Reporter: Andreas Schwab <schwab>
Component: kjsAssignee: Konqueror Developers <konq-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: b.buschinski
Priority: NOR    
Version: 4.8.5   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Avoid overflow when computing availableStackSize from stack limit

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)