summaryrefslogtreecommitdiff
path: root/sql/gen_lex_hash.cc
diff options
context:
space:
mode:
authorunknown <cmiller@maint1.mysql.com>2006-08-23 19:14:58 +0200
committerunknown <cmiller@maint1.mysql.com>2006-08-23 19:14:58 +0200
commitf9832bf116b2525afa79267cfea6cd8360e418f6 (patch)
treee788abcd6fb6c865ebd76205fbd4c28799bad97b /sql/gen_lex_hash.cc
parent75e40b161b5cbbea28eca2641e6dfadaf09267a1 (diff)
downloadmariadb-git-f9832bf116b2525afa79267cfea6cd8360e418f6.tar.gz
Bug #20908: Crash if select @@""
Zero-length variables caused failures when using the length to look up the name in a hash. Instead, signal that no zero-length name can ever be found and that to encounter one is a syntax error. mysql-test/r/variables.result: Results for test. mysql-test/t/variables.test: Insert tests to prove that zero-length variable names do not cause faults. sql/gen_lex_hash.cc: If the length is zero, then there is nothing to look-up in the hash. sql/sql_lex.cc: Names of variables must not be empty. Signal an error of that happens.
Diffstat (limited to 'sql/gen_lex_hash.cc')
-rw-r--r--sql/gen_lex_hash.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc
index 7e0b178f7af..89af0d30076 100644
--- a/sql/gen_lex_hash.cc
+++ b/sql/gen_lex_hash.cc
@@ -447,8 +447,9 @@ int main(int argc,char **argv)
and you are welcome to modify and redistribute it under the GPL license\n\
\n*/\n\n");
- printf("/* This code is generated by gen_lex_hash.cc that seeks for\
- a perfect\nhash function */\n\n");
+ /* Broken up to indicate that it's not advice to you, gentle reader. */
+ printf("/* Do " "not " "edit " "this " "file! This is generated by "
+ "gen_lex_hash.cc\nthat seeks for a perfect hash function */\n\n");
printf("#include \"lex.h\"\n\n");
calc_length();
@@ -468,6 +469,12 @@ static inline SYMBOL *get_hash_symbol(const char *s,\n\
{\n\
register uchar *hash_map;\n\
register const char *cur_str= s;\n\
+\n\
+ if (len == 0) {\n\
+ DBUG_PRINT(\"warning\", (\"get_hash_symbol() received a request for a zero-length symbol, which is probably a mistake.\"));\
+ return(NULL);\n\
+ }\
+\n\
if (function){\n\
if (len>sql_functions_max_len) return 0;\n\
hash_map= sql_functions_map;\n\