shithub: libmujs

Download patch

ref: 6871e5b41c07558b17340f985f2af39717d3ba77
parent: 6a9eedea88d4194407f8c0a578e4458f73b7364d
author: Tor Andersson <tor.andersson@artifex.com>
date: Tue Sep 8 06:49:26 EDT 2020

Issue #141: Add missing end-of-string checks in regexp lexer.

--- a/regexp.c
+++ b/regexp.c
@@ -132,9 +132,13 @@
 		case 't': g->yychar = '\t'; return 0;
 		case 'v': g->yychar = '\v'; return 0;
 		case 'c':
+			if (!g->source[0])
+				die(g, "unterminated escape sequence");
 			g->yychar = (*g->source++) & 31;
 			return 0;
 		case 'x':
+			if (!g->source[0] || !g->source[1])
+				die(g, "unterminated escape sequence");
 			g->yychar = hex(g, *g->source++) << 4;
 			g->yychar += hex(g, *g->source++);
 			if (g->yychar == 0) {
@@ -143,6 +147,8 @@
 			}
 			return 0;
 		case 'u':
+			if (!g->source[0] || !g->source[1] || !g->source[2] || !g->source[3])
+				die(g, "unterminated escape sequence");
 			g->yychar = hex(g, *g->source++) << 12;
 			g->yychar += hex(g, *g->source++) << 8;
 			g->yychar += hex(g, *g->source++) << 4;