Welcome! Log In Create A New Profile

Advanced

[njs] Fixed heap-buffer-overflow in lexer introduced in 87d05fb35ff9.

Alexander Borisov
February 27, 2020 06:32AM
details: https://hg.nginx.org/njs/rev/3313d0d593a0
branches:
changeset: 1340:3313d0d593a0
user: Alexander Borisov <alexander.borisov@nginx.com>
date: Thu Feb 27 14:30:14 2020 +0300
description:
Fixed heap-buffer-overflow in lexer introduced in 87d05fb35ff9.

diffstat:

src/njs_lexer.c | 2 +-
src/test/njs_unit_test.c | 15 +++++++++++++++
2 files changed, 16 insertions(+), 1 deletions(-)

diffs (37 lines):

diff -r 6444ae6ab276 -r 3313d0d593a0 src/njs_lexer.c
--- a/src/njs_lexer.c Wed Feb 26 17:48:46 2020 +0300
+++ b/src/njs_lexer.c Thu Feb 27 14:30:14 2020 +0300
@@ -864,7 +864,7 @@ njs_lexer_multi(njs_lexer_t *lexer, njs_

token->text.start = lexer->start - 1;

- while (length != 0 && multi != NULL) {
+ while (length != 0 && multi != NULL && lexer->start < lexer->end) {
c = lexer->start[0];

if (c == multi->symbol) {
diff -r 6444ae6ab276 -r 3313d0d593a0 src/test/njs_unit_test.c
--- a/src/test/njs_unit_test.c Wed Feb 26 17:48:46 2020 +0300
+++ b/src/test/njs_unit_test.c Thu Feb 27 14:30:14 2020 +0300
@@ -33,6 +33,21 @@ static njs_unit_test_t njs_test[] =
{ njs_str("/***/1/*\n**/"),
njs_str("1") },

+ { njs_str(">"),
+ njs_str("SyntaxError: Unexpected token \">\" in 1") },
+
+ { njs_str(">>"),
+ njs_str("SyntaxError: Unexpected token \">>\" in 1") },
+
+ { njs_str(">>>"),
+ njs_str("SyntaxError: Unexpected token \">>>\" in 1") },
+
+ { njs_str("=="),
+ njs_str("SyntaxError: Unexpected token \"==\" in 1") },
+
+ { njs_str("?"),
+ njs_str("SyntaxError: Unexpected token \"?\" in 1") },
+
/* Variable declarations. */

{ njs_str("var x"),
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Fixed heap-buffer-overflow in lexer introduced in 87d05fb35ff9.

Alexander Borisov 65 February 27, 2020 06:32AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 74
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready