From 9036f1aa97ad0a46a338b70673327dd3d8192eee Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Thu, 5 Feb 2009 10:16:00 +0400 Subject: Bug#37995 Error message truncation in test "innodb" in embedded mode. code backported from 6.0 per-file messages: include/my_global.h Remove SC_MAXWIDTH. This is unused and irrelevant nowadays. include/my_sys.h Remove errbuf declaration and unused definitions. mysys/my_error.c Remove errbuf definition and move and adjust ERRMSGSIZE. mysys/my_init.c Declare buffer on the stack and use my_snprintf. mysys/safemalloc.c Use size explicitly. It's more than enough for the message at hand. sql/sql_error.cc Use size explicitly. It's more than enough for the message at hand. sql/sql_parse.cc Declare buffer on the stack. Use my_snprintf as it will result in less stack space being used than by a system provided sprintf -- this allows us to put the buffer on the stack without causing much trouble. Also, the use of errbuff here was not thread-safe as the function can be entered concurrently from multiple threads. sql/sql_table.cc Use MYSQL_ERRMSG_SIZE. Extra space is not needed as my_snprintf will nul terminate strings. storage/myisam/ha_myisam.cc Use MYSQL_ERRMSG_SIZE. sql/share/errmsg.txt Error message truncation in test "innodb" in embedded mode filename in the error message can safely take up to 210 symbols. --- mysys/my_error.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'mysys/my_error.c') diff --git a/mysys/my_error.c b/mysys/my_error.c index 75701536dd3..07656dda979 100644 --- a/mysys/my_error.c +++ b/mysys/my_error.c @@ -19,6 +19,10 @@ #include #include +/* Max length of a error message. Should be kept in sync with MYSQL_ERRMSG_SIZE. */ +#define ERRMSGSIZE (512) + + /* Define some external variables for error handling */ /* @@ -30,8 +34,6 @@ my_printf_error(ER_CODE, format, MYF(N), ...) */ -char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE]; - /* Message texts are registered into a linked list of 'my_err_head' structs. Each struct contains (1.) an array of pointers to C character strings with @@ -75,7 +77,7 @@ int my_error(int nr, myf MyFlags, ...) const char *format; struct my_err_head *meh_p; va_list args; - char ebuff[ERRMSGSIZE + 20]; + char ebuff[ERRMSGSIZE]; DBUG_ENTER("my_error"); DBUG_PRINT("my", ("nr: %d MyFlags: %d errno: %d", nr, MyFlags, errno)); @@ -112,7 +114,7 @@ int my_error(int nr, myf MyFlags, ...) int my_printf_error(uint error, const char *format, myf MyFlags, ...) { va_list args; - char ebuff[ERRMSGSIZE+20]; + char ebuff[ERRMSGSIZE]; DBUG_ENTER("my_printf_error"); DBUG_PRINT("my", ("nr: %d MyFlags: %d errno: %d Format: %s", error, MyFlags, errno, format)); -- cgit v1.2.1