From 184df0393edac205e6d6ecde7621bee54b32401d Mon Sep 17 00:00:00 2001 From: Eliran Sinvani Date: Wed, 12 Jun 2019 16:31:51 +0300 Subject: [PATCH] cql: Fix crash upon use of the word empty for service level name Wrong access to an uninitialized token instead of the actual generated string caused the parser to crash, this wasn't detected by the ANTLR3 compiler because all the temporary variables defined in the ANTLR3 statements are global in the generated code. This essentialy caused a null dereference. Tests: 1. The fixed issue scenario from github. 2. Unit tests in release mode. Fixes #11774 Signed-off-by: Eliran Sinvani Message-Id: <20190612133151.20609-1-eliransin@scylladb.com> Closes #11777 (cherry picked from commit ab7429b77d95a25dbf1abacab76d231bb71cbc98) --- cql3/Cql.g | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cql3/Cql.g b/cql3/Cql.g index 681eda88d3..5ae38a15f2 100644 --- a/cql3/Cql.g +++ b/cql3/Cql.g @@ -1386,7 +1386,7 @@ serviceLevelOrRoleName returns [sstring name] std::transform($name.begin(), $name.end(), $name.begin(), ::tolower); } | t=STRING_LITERAL { $name = sstring($t.text); } | t=QUOTED_NAME { $name = sstring($t.text); } -| k=unreserved_keyword { $name = sstring($t.text); +| k=unreserved_keyword { $name = k; std::transform($name.begin(), $name.end(), $name.begin(), ::tolower);} | QMARK {add_recognition_error("Bind variables cannot be used for service levels or role names");} ;