diff options
author | unknown <svoj@mysql.com/june.mysql.com> | 2008-03-20 19:07:17 +0400 |
---|---|---|
committer | unknown <svoj@mysql.com/june.mysql.com> | 2008-03-20 19:07:17 +0400 |
commit | 8030bdfc16a647c15e0de5e07b5f53d263ef5ca2 (patch) | |
tree | 0ea585c816f892e7d7167a1ef6f609196a3a0bb3 /sql/ha_federated.cc | |
parent | 7343db297a1f1ab08812c9b4471306535551ddec (diff) | |
download | mariadb-git-8030bdfc16a647c15e0de5e07b5f53d263ef5ca2.tar.gz |
BUG#34788 - malformed federated connection url is not handled
correctly - crashes server !
Creating federated table with connect string containing empty
(zero-length) host name and port is evaluated as 0 (port is
incorrect, omitted or 0) crashes server.
This happens because federated calls strcmp() with NULL pointer.
Fixed by avoiding strcmp() call if hostname is set to NULL.
mysql-test/r/federated.result:
A test case for BUG#34788.
mysql-test/t/federated.test:
A test case for BUG#34788.
sql/ha_federated.cc:
Fixed that parse_url() may call strcmp() with NULL pointer.
Diffstat (limited to 'sql/ha_federated.cc')
-rw-r--r-- | sql/ha_federated.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc index c0743bd6c9a..a5e4714c53a 100644 --- a/sql/ha_federated.cc +++ b/sql/ha_federated.cc @@ -643,12 +643,19 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table, if ((strchr(share->table_name, '/'))) goto error; + /* + If hostname is omitted, we set it to NULL. According to + mysql_real_connect() manual: + The value of host may be either a hostname or an IP address. + If host is NULL or the string "localhost", a connection to the + local host is assumed. + */ if (share->hostname[0] == '\0') share->hostname= NULL; if (!share->port) { - if (strcmp(share->hostname, my_localhost) == 0) + if (!share->hostname || strcmp(share->hostname, my_localhost) == 0) share->socket= my_strdup(MYSQL_UNIX_ADDR, MYF(0)); else share->port= MYSQL_PORT; |