Commit d0c5efc4 authored by Monty's avatar Monty

If one compiled with too long MYSQL_SERVER_SUFFIX this caused a memory

overrun that caused some test to fail.

Fixed by ensuring we don't overwrite "server_version"
parent a1ddf014
...@@ -7386,7 +7386,7 @@ static int mysql_init_variables(void) ...@@ -7386,7 +7386,7 @@ static int mysql_init_variables(void)
global_query_id= thread_id= 1L; global_query_id= thread_id= 1L;
my_atomic_rwlock_init(&global_query_id_lock); my_atomic_rwlock_init(&global_query_id_lock);
my_atomic_rwlock_init(&thread_running_lock); my_atomic_rwlock_init(&thread_running_lock);
strmov(server_version, MYSQL_SERVER_VERSION); strnmov(server_version, MYSQL_SERVER_VERSION, sizeof(server_version)-1);
threads.empty(); threads.empty();
thread_cache.empty(); thread_cache.empty();
key_caches.empty(); key_caches.empty();
...@@ -8113,17 +8113,20 @@ static int get_options(int *argc_ptr, char ***argv_ptr) ...@@ -8113,17 +8113,20 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
void set_server_version(void) void set_server_version(void)
{ {
char *end= strxmov(server_version, MYSQL_SERVER_VERSION, char *version_end= server_version+sizeof(server_version)-1;
MYSQL_SERVER_SUFFIX_STR, NullS); char *end= strxnmov(server_version, sizeof(server_version)-1,
MYSQL_SERVER_VERSION,
MYSQL_SERVER_SUFFIX_STR, NullS);
#ifdef EMBEDDED_LIBRARY #ifdef EMBEDDED_LIBRARY
end= strmov(end, "-embedded"); end= strnmov(end, "-embedded", (version_end-end));
#endif #endif
#ifndef DBUG_OFF #ifndef DBUG_OFF
if (!strstr(MYSQL_SERVER_SUFFIX_STR, "-debug")) if (!strstr(MYSQL_SERVER_SUFFIX_STR, "-debug"))
end= strmov(end, "-debug"); end= strnmov(end, "-debug", (version_end-end));
#endif #endif
if (opt_log || opt_slow_log || opt_bin_log) if (opt_log || opt_slow_log || opt_bin_log)
strmov(end, "-log"); // This may slow down system strnmov(end, "-log", (version_end-end)); // This may slow down system
*end= 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment