summaryrefslogtreecommitdiff
path: root/sql-common
diff options
context:
space:
mode:
authortnurnberg@sin.intern.azundris.com <>2007-06-21 04:30:10 +0200
committertnurnberg@sin.intern.azundris.com <>2007-06-21 04:30:10 +0200
commit3c1be0006917b60c65a2633f8c56b8b6c1da50fb (patch)
treefea7dab54027f4bcf1a6f14812101fc2716da4f3 /sql-common
parentbd80d7e46570988c06e140704848c7749faf272c (diff)
downloadmariadb-git-3c1be0006917b60c65a2633f8c56b8b6c1da50fb.tar.gz
Bug#24924: shared-memory-base-name that is too long causes buffer overflow
long shared-memory-base-names could overflow a static internal buffer and thus crash mysqld and various clients. change both to dynamic buffers, show everything but overflowing those buffers still works. The test case for this would pretty much amount to mysqld --shared-memory-base-name=HeyMrBaseNameXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --shared-memory=1 & mysqladmin --no-defaults --shared-memory-base-name=HeyMrBaseNameXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX shutdown Unfortunately, we can't just use an .opt file for the server. The .opt file is used at start-up, before any include in the actual test can tell mysqltest to skip this one on non-Windows. As a result, such a test would break on unices. Fixing mysql-test-run.pl to export full path for master and slave would enable us to start a server from within the test which is ugly and, what's more, doesn't work as the server blocks (mysqltest offers no fire-and-forget fork-and-exec), and mysqladmin never gets run. Making the test rpl_windows_shm or some such so we can is beyond ugly. As is introducing another file-name based special case (run "win*.test" only when on Windows). As is (yuck) coding half the test into mtr (as in, having it hand out a customized environment conductive to the shm- thing on Win only). Situation is exacerbated by the fact that .sh is not necessary run as expected on Win. In short, it's just not worth it. No test-case until we have a new-and-improved test framework.
Diffstat (limited to 'sql-common')
-rw-r--r--sql-common/client.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/sql-common/client.c b/sql-common/client.c
index 3e5ceb1a738..f8d52e02196 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -402,7 +402,7 @@ HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout)
HANDLE handle_file_map = NULL;
ulong connect_number;
char connect_number_char[22], *p;
- char tmp[64];
+ char *tmp= NULL;
char *suffix_pos;
DWORD error_allow = 0;
DWORD error_code = 0;
@@ -410,6 +410,12 @@ HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout)
char *shared_memory_base_name = mysql->options.shared_memory_base_name;
/*
+ get enough space base-name + '_' + longest suffix we might ever send
+ */
+ if (!(tmp= (char *)my_malloc(strlen(shared_memory_base_name) + 32L, MYF(MY_FAE))))
+ goto err;
+
+ /*
The name of event and file-mapping events create agree next rule:
shared_memory_base_name+unique_part
Where:
@@ -551,6 +557,8 @@ err2:
CloseHandle(handle_file_map);
}
err:
+ if (tmp)
+ my_free(tmp, MYF(0));
if (error_allow)
error_code = GetLastError();
if (event_connect_request)