summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorDmitry Shulga <Dmitry.Shulga@oracle.com>2011-02-04 10:47:46 +0600
committerDmitry Shulga <Dmitry.Shulga@oracle.com>2011-02-04 10:47:46 +0600
commit378091e434d66dcc7081f991a07db2244dbb8cda (patch)
treed9c23034dd5cc3bd26c4dce059805d050030408d /sql
parenta265fde655316a4c1b1702bb97dd7fdde621f55c (diff)
downloadmariadb-git-378091e434d66dcc7081f991a07db2244dbb8cda.tar.gz
Fixed bug#58026 - massive recursion and crash in regular expression
handling. The problem was that parsing of nested regular expression involved recursive calls. Such recursion didn't take into account the amount of available stack space, which ended up leading to stack overflow crashes. mysql-test/t/not_embedded_server.test: Added test for bug#58026. regex/my_regex.h: added pointer to function as last argument of my_regex_init() for check enough memory in stack. regex/regcomp.c: p_ere() was modified: added call to function for check enough memory in stack. Function for check available stack space specified by global variable my_regex_enough_mem_in_stack. This variable set to NULL for embedded mysqld and to a pointer to function check_enough_stack_size otherwise. regex/reginit.c: my_regex_init was modified: pass a pointer to a function for check enough memory in stack space. Reset this pointer to NULL in my_regex_end. sql/mysqld.cc: Added function check_enough_stack_size() for check enough memory in stack. Passed this function as second argument to my_regex_init. For embedded mysqld passed NULL as second argument.
Diffstat (limited to 'sql')
-rw-r--r--sql/mysqld.cc19
1 files changed, 18 insertions, 1 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 54f93cccd5d..694d64c81df 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -3034,6 +3034,19 @@ sizeof(load_default_groups)/sizeof(load_default_groups[0]);
#endif
+#ifndef EMBEDDED_LIBRARY
+static
+int
+check_enough_stack_size()
+{
+ uchar stack_top;
+
+ return check_stack_overrun(current_thd, STACK_MIN_SIZE,
+ &stack_top);
+}
+#endif
+
+
/**
Initialize one of the global date/time format variables.
@@ -3415,7 +3428,11 @@ static int init_common_variables(const char *conf_file_name, int argc,
#endif
mysys_uses_curses=0;
#ifdef USE_REGEX
- my_regex_init(&my_charset_latin1);
+#ifndef EMBEDDED_LIBRARY
+ my_regex_init(&my_charset_latin1, check_enough_stack_size);
+#else
+ my_regex_init(&my_charset_latin1, NULL);
+#endif
#endif
/*
Process a comma-separated character set list and choose