summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/federated.result2
-rw-r--r--mysql-test/t/federated.test12
-rw-r--r--storage/federated/ha_federated.cc17
3 files changed, 26 insertions, 5 deletions
diff --git a/mysql-test/r/federated.result b/mysql-test/r/federated.result
index 98e6569fa36..65fafcb2166 100644
--- a/mysql-test/r/federated.result
+++ b/mysql-test/r/federated.result
@@ -2090,6 +2090,8 @@ a b
1 1
DROP TABLE t1;
DROP TABLE t1;
+CREATE TABLE t1 (a INT) ENGINE=federated CONNECTION='mysql://@:://';
+DROP TABLE t1;
End of 5.1 tests
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE IF EXISTS federated;
diff --git a/mysql-test/t/federated.test b/mysql-test/t/federated.test
index 79a706fdfa2..9d36e0e0cfc 100644
--- a/mysql-test/t/federated.test
+++ b/mysql-test/t/federated.test
@@ -1816,5 +1816,17 @@ DROP TABLE t1;
connection slave;
DROP TABLE t1;
+#
+# BUG#34788 - malformed federated connection url is not handled correctly -
+# crashes server !
+#
+# also tests
+#
+# BUG#35509 - Federated leaks memory when connecting to localhost/default
+# port
+#
+CREATE TABLE t1 (a INT) ENGINE=federated CONNECTION='mysql://@:://';
+DROP TABLE t1;
+
--echo End of 5.1 tests
source include/federated_cleanup.inc;
diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc
index d7040c44fe8..ec99b47ce65 100644
--- a/storage/federated/ha_federated.cc
+++ b/storage/federated/ha_federated.cc
@@ -794,9 +794,9 @@ static int parse_url(MEM_ROOT *mem_root, FEDERATED_SHARE *share, TABLE *table,
goto error;
/*
Found that if the string is:
-user:@hostname:port/db/table
-Then password is a null string, so set to NULL
- */
+ user:@hostname:port/db/table
+ Then password is a null string, so set to NULL
+ */
if ((share->password[0] == '\0'))
share->password= NULL;
}
@@ -833,14 +833,21 @@ Then password is a null string, so set to NULL
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)
- share->socket= (char *) MYSQL_UNIX_ADDR;
+ if (!share->hostname || strcmp(share->hostname, my_localhost) == 0)
+ share->socket= (char*) MYSQL_UNIX_ADDR;
else
share->port= MYSQL_PORT;
}