summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Vojtovich <sergey.vojtovich@oracle.com>2010-12-08 15:10:11 +0300
committerSergey Vojtovich <sergey.vojtovich@oracle.com>2010-12-08 15:10:11 +0300
commit9588e1ba53fa91463c4ad5695c46f821aa2ade7b (patch)
treed049239e7002e7351c1006894f711c5e80b134f1
parent899038030ab0fdcba1e72efce46c98f409802099 (diff)
parent21779b35eaf0bbbd9aad6c220012a12ff001cc11 (diff)
downloadmariadb-git-9588e1ba53fa91463c4ad5695c46f821aa2ade7b.tar.gz
Merge fix for BUG58205 to 5.5-bugteam.
-rw-r--r--mysql-test/r/archive.result6
-rw-r--r--mysql-test/t/archive.test8
-rw-r--r--mysys/mf_pack.c3
-rw-r--r--storage/archive/ha_archive.cc3
4 files changed, 18 insertions, 2 deletions
diff --git a/mysql-test/r/archive.result b/mysql-test/r/archive.result
index 028c8b32f87..231b7acb5b4 100644
--- a/mysql-test/r/archive.result
+++ b/mysql-test/r/archive.result
@@ -12801,3 +12801,9 @@ t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
DROP TABLE t1;
+#
+# BUG#58205 - Valgrind failure in fn_format when called from
+# archive_discover
+#
+CREATE TABLE `a/../`(a INT) ENGINE=ARCHIVE;
+DROP TABLE `a/../`;
diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test
index c3a080612a9..ce5047124a2 100644
--- a/mysql-test/t/archive.test
+++ b/mysql-test/t/archive.test
@@ -1722,3 +1722,11 @@ INSERT INTO t1 VALUES (2);
SELECT * FROM t1 ORDER BY a;
SHOW CREATE TABLE t1;
DROP TABLE t1;
+
+--echo #
+--echo # BUG#58205 - Valgrind failure in fn_format when called from
+--echo # archive_discover
+--echo #
+CREATE TABLE `a/../`(a INT) ENGINE=ARCHIVE;
+remove_file $MYSQLD_DATADIR/test/a@002f@002e@002e@002f.frm;
+DROP TABLE `a/../`;
diff --git a/mysys/mf_pack.c b/mysys/mf_pack.c
index c6e6a3a429e..a9482187138 100644
--- a/mysys/mf_pack.c
+++ b/mysys/mf_pack.c
@@ -192,7 +192,8 @@ size_t cleanup_dirname(register char *to, const char *from)
end_parentdir=pos;
while (pos >= start && *pos != FN_LIBCHAR) /* remove prev dir */
pos--;
- if (pos[1] == FN_HOMELIB || memcmp(pos,parent,length) == 0)
+ if (pos[1] == FN_HOMELIB ||
+ (pos > start && memcmp(pos, parent, length) == 0))
{ /* Don't remove ~user/ */
pos=strmov(end_parentdir+1,parent);
*pos=FN_LIBCHAR;
diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc
index c24fbc21f94..fe167318743 100644
--- a/storage/archive/ha_archive.cc
+++ b/storage/archive/ha_archive.cc
@@ -20,6 +20,7 @@
#include "sql_priv.h"
#include "probes_mysql.h"
#include "sql_class.h" // SSV
+#include "sql_table.h"
#include <myisam.h>
#include "ha_archive.h"
@@ -256,7 +257,7 @@ int archive_discover(handlerton *hton, THD* thd, const char *db,
char *frm_ptr;
MY_STAT file_stat;
- fn_format(az_file, name, db, ARZ, MY_REPLACE_EXT | MY_UNPACK_FILENAME);
+ build_table_filename(az_file, sizeof(az_file) - 1, db, name, ARZ, 0);
if (!(my_stat(az_file, &file_stat, MYF(0))))
goto err;