summaryrefslogtreecommitdiff
path: root/sql/sql_parse.cc
diff options
context:
space:
mode:
authorunknown <hf@deer.(none)>2004-02-11 16:36:33 +0400
committerunknown <hf@deer.(none)>2004-02-11 16:36:33 +0400
commit861d3f415254aa936478c43d36988e83dd3844f5 (patch)
tree8025eb832a035349ab78f022033d81d125ad2a30 /sql/sql_parse.cc
parente5c142a412f1c2ead19f8d8612e4278ffe92495e (diff)
parente2f0e8f2dc6ed325a577aa9bd52dd4e6d206dd34 (diff)
downloadmariadb-git-861d3f415254aa936478c43d36988e83dd3844f5.tar.gz
Merge abotchkov@bk-internal.mysql.com:/home/bk/mysql-4.1
into deer.(none):/home/hf/work/mysql-4.1.2208 sql/sql_parse.cc: Auto merged
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r--sql/sql_parse.cc18
1 files changed, 17 insertions, 1 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 51e1ebee4ad..81d6b80678d 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -3854,7 +3854,23 @@ 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 (!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)))
{
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if (mqh_used && thd->user_connect &&