Commit Graph

16 Commits

Author SHA1 Message Date
Tor Andersson
7f50591861 Bug 700429: Limit size of input regular expression program.
The size of the parsed syntax list could overflow. Allowing it to be
bigger than the compiled program makes no sense, so use the same size
limit when parsing as when compiling.
2019-01-02 16:05:24 +01:00
Tor Andersson
fcf0e3ebd7 Tweak numeric overflow check in regexp count parser. 2018-11-26 10:40:22 +01:00
Sebastian Rasmussen
7448a82448 Fix gcc compiler warnings about switch fallthroughs. 2018-09-11 12:47:31 +02:00
Sebastian Rasmussen
c86267d8b2 Fix issue 66: Stack overflow when compiling long regexp sequences.
The syntax tree for long chains of Cat nodes leaned leftwards, which
made the compile() step potentially run out of stack. If we build the
Cat tree leaning right, we can use an iterative loop instead of
recursion.
2018-07-30 15:35:39 +02:00
Tor Andersson
5c1300b015 Fix 699559: Off-by-one comparison in regexp parser. 2018-07-26 23:44:15 +02:00
Tor Andersson
22430de3a9 Fix creation of empty regular expressions.
Handle empty regular expressions in RegExp compiler asserts.

Also turn them into /(?:)/ on the JS side, so they can be printed
back as valid JS syntax where // is a comment, not a regular expression.
2018-05-03 10:45:34 +02:00
Tor Andersson
557968a22d Reduce minimum stack use in regexec by using recursive implementation. 2017-08-15 14:08:55 +02:00
Tor Andersson
c8934909e0 Silence a few compiler warnings for harmless, impossible cases.
The 'save' variable is *always* set before it's accessed, but the logic
is too difficult for gcc to trace.

node->m is always > 0, but the compiler has no way of knowing.
2017-06-19 11:50:13 +02:00
Tor Andersson
fb32b5c893 Add a js_setreport callback function to report warnings.
Don't print error and warning messages directly to stderr.
2017-05-16 12:03:38 +02:00
Tor Andersson
581412fba5 Optimize regexp interpreter loop.
Only jump once after each instruction.
2017-03-30 13:00:35 +02:00
Tor Andersson
fa3d30fd18 Fix 697448: Limit the maximum program size to something reasonable.
A regular expression with lots of nested repetition can lead to
integer overflow when calculating the size of the program.

Check max program size when counting the number of instructions required
for a loop, so we can bail before integer overflow can happen.
2017-01-12 15:30:42 +01:00
Tor Andersson
fd003eceda Fix 697381: check allocation when compiling regular expressions.
Also use allocator callback function.
2016-12-02 14:58:17 -05:00
Tor Andersson
b6de34ac6d Fix 697281: numeric overflow in regular expression repetition count. 2016-10-31 12:58:24 +01:00
Tor Andersson
1930f35933 Fix \s and \S ranges in regular expression. 2016-05-04 12:13:50 +02:00
Tor Andersson
3e3c382a0c Avoid using 'unsigned int'.
Mixing signed and unsigned ints is just a plain headache.
2016-04-27 16:26:00 +02:00
Tor Andersson
eed7619158 Rename our internal regex.h to not collide with system regex.h. 2015-08-14 12:05:09 +02:00