summaryrefslogtreecommitdiff
path: root/sql/sql_lex.cc
diff options
context:
space:
mode:
authorDmitry Shulga <dmitry.shulga@mariadb.com>2021-01-12 14:30:08 +0700
committerDmitry Shulga <dmitry.shulga@mariadb.com>2021-01-12 14:30:08 +0700
commit787f7b11780e0248d9f5ef9cd31a3539e129964f (patch)
treeb61d039e5467e21587909a11abd7a53b4ef94efb /sql/sql_lex.cc
parent5a1a7141870459cf66d8e441b443187f87a10d5d (diff)
downloadmariadb-git-bb-10.3-MDEV-23666.tar.gz
MDEV-23666: Assertion `m_cpp_buf <= ptr && ptr <= m_cpp_buf + m_buf_length' failed in Lex_input_stream::body_utf8_appendbb-10.3-MDEV-23666
On parsing statements for which a starting backtick (`) delimiter doesn't have a corresponding ending backtick, a current pointer to a position inside a pre-processed buffer could go beyond the end of the buffer. This bug report caused by the commit d4967659032b18a5504198b41dd3d0a1813d79ef "MDEV-22022 Various mangled SQL statements will crash 10.3 to 10.5 debug builds". In order to fix the issue both pointers m_ptr and m_cpp_ptr must be rolled back to previous position in raw input and pre-processed input streams correspondingly in case end of query reached during parsing.
Diffstat (limited to 'sql/sql_lex.cc')
-rw-r--r--sql/sql_lex.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 6116dee6e7e..b8f6610e066 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -2215,6 +2215,8 @@ int Lex_input_stream::scan_ident_delimited(THD *thd,
Return the quote character, to have the parser fail on syntax error.
*/
m_ptr= (char *) m_tok_start + 1;
+ if (m_echo)
+ m_cpp_ptr= (char *) m_cpp_tok_start + 1;
return quote_char;
}
int var_length= my_charlen(cs, get_ptr() - 1, get_end_of_query());