Skip to content

Commit d0c5efc

Browse files
committed
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"
1 parent a1ddf01 commit d0c5efc

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

sql/mysqld.cc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7386,7 +7386,7 @@ static int mysql_init_variables(void)
73867386
global_query_id= thread_id= 1L;
73877387
my_atomic_rwlock_init(&global_query_id_lock);
73887388
my_atomic_rwlock_init(&thread_running_lock);
7389-
strmov(server_version, MYSQL_SERVER_VERSION);
7389+
strnmov(server_version, MYSQL_SERVER_VERSION, sizeof(server_version)-1);
73907390
threads.empty();
73917391
thread_cache.empty();
73927392
key_caches.empty();
@@ -8113,17 +8113,20 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
81138113

81148114
void set_server_version(void)
81158115
{
8116-
char *end= strxmov(server_version, MYSQL_SERVER_VERSION,
8117-
MYSQL_SERVER_SUFFIX_STR, NullS);
8116+
char *version_end= server_version+sizeof(server_version)-1;
8117+
char *end= strxnmov(server_version, sizeof(server_version)-1,
8118+
MYSQL_SERVER_VERSION,
8119+
MYSQL_SERVER_SUFFIX_STR, NullS);
81188120
#ifdef EMBEDDED_LIBRARY
8119-
end= strmov(end, "-embedded");
8121+
end= strnmov(end, "-embedded", (version_end-end));
81208122
#endif
81218123
#ifndef DBUG_OFF
81228124
if (!strstr(MYSQL_SERVER_SUFFIX_STR, "-debug"))
8123-
end= strmov(end, "-debug");
8125+
end= strnmov(end, "-debug", (version_end-end));
81248126
#endif
81258127
if (opt_log || opt_slow_log || opt_bin_log)
8126-
strmov(end, "-log"); // This may slow down system
8128+
strnmov(end, "-log", (version_end-end)); // This may slow down system
8129+
*end= 0;
81278130
}
81288131

81298132

0 commit comments

Comments
 (0)