1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +03:00
"MySQL server does not detect if garbage chara at the end of query"

Allow the parser to see the garbage characters.
Garbage should cause the parser to report an error.
This commit is contained in:
acurtis@pcgem.rdg.cyberkinetica.com
2004-02-12 12:01:27 +00:00
parent 8e6a2e98ae
commit a316e2f9e5
3 changed files with 9 additions and 28 deletions

View File

@@ -3854,23 +3854,7 @@ mysql_parse(THD *thd, char *inBuf, uint length)
if (query_cache_send_result_to_client(thd, inBuf, length) <= 0)
{
LEX *lex=lex_start(thd, (uchar*) inBuf, length);
if (!yyparse((void *)thd) && ! thd->is_fatal_error &&
/*
If this is not a multiple query, ensure that it has been
successfully parsed until the last character. This is to prevent
against a wrong (too big) length passed to mysql_real_query(),
mysql_prepare()... which can generate garbage characters at the
end. If the query was initially multiple, found_colon will be false
only when we are in the last query; this last query had already
been end-spaces-stripped by alloc_query() in dispatch_command(); as
end spaces are the only thing we accept at the end of a query, and
they have been stripped already, here we can require that nothing
remains after parsing.
*/
(thd->lex->found_colon ||
(char*)(thd->lex->ptr) == (thd->query+thd->query_length+1) ||
/* yyerror() will show the garbage chars to the user */
(yyerror("syntax error"), 0)))
if (!yyparse((void *)thd) && ! thd->is_fatal_error)
{
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if (mqh_used && thd->user_connect &&