#At file:///home/ram/mysql/b44774-5.0-bugteam/ based on revid:ramil@stripped
2737 Ramil Kalimullin 2009-05-12
Fix for bug#44774: load_file function produces valgrind warnings
Problem: using LOAD_FILE() in some cases we pass a file name string
without a trailing '\0' to fn_format() which relies on that however.
That may lead to valgrind warnings.
Fix: add a trailing '\0' to the file name passed to fn_format().
@ mysql-test/r/func_str.result
Fix for bug#44774: load_file function produces valgrind warnings
- test result.
@ mysql-test/t/func_str.test
Fix for bug#44774: load_file function produces valgrind warnings
- test case.
@ sql/item_strfunc.cc
Fix for bug#44774: load_file function produces valgrind warnings
- added a trailing '\0' to file name passed to fn_format().
- file_name->c_ptr() replaced with file_name->ptr() accordingly.
modified:
mysql-test/r/func_str.result
mysql-test/t/func_str.test
sql/item_strfunc.cc
=== modified file 'mysql-test/r/func_str.result'
--- a/mysql-test/r/func_str.result 2009-02-14 09:09:35 +0000
+++ b/mysql-test/r/func_str.result 2009-05-12 06:12:43 +0000
@@ -2187,4 +2187,13 @@ SELECT DATE_FORMAT(c, GET_FORMAT(DATE, '
h i
31.12.2008 AAAAAA, aaaaaa
DROP TABLE t1;
+#
+# BUG#44774: load_file function produces valgrind warnings
+#
+CREATE TABLE t1 (a TINYBLOB);
+INSERT INTO t1 VALUES ('aaaaaaaa');
+SELECT LOAD_FILE('a') FROM t1;
+LOAD_FILE('a')
+NULL
+DROP TABLE t1;
End of 5.0 tests
=== modified file 'mysql-test/t/func_str.test'
--- a/mysql-test/t/func_str.test 2009-02-13 16:17:07 +0000
+++ b/mysql-test/t/func_str.test 2009-05-12 06:12:43 +0000
@@ -1168,4 +1168,14 @@ INSERT INTO t1 VALUES ('2008-12-31','aaa
SELECT DATE_FORMAT(c, GET_FORMAT(DATE, 'eur')) h, CONCAT(UPPER(aa),', ', aa) i FROM t1;
DROP TABLE t1;
+
+--echo #
+--echo # BUG#44774: load_file function produces valgrind warnings
+--echo #
+CREATE TABLE t1 (a TINYBLOB);
+INSERT INTO t1 VALUES ('aaaaaaaa');
+SELECT LOAD_FILE('a') FROM t1;
+DROP TABLE t1;
+
+
--echo End of 5.0 tests
=== modified file 'sql/item_strfunc.cc'
--- a/sql/item_strfunc.cc 2009-04-17 15:52:57 +0000
+++ b/sql/item_strfunc.cc 2009-05-12 06:12:43 +0000
@@ -2825,14 +2825,15 @@ String *Item_load_file::val_str(String *
char path[FN_REFLEN];
DBUG_ENTER("load_file");
- if (!(file_name= args[0]->val_str(str))
+ if (!(file_name= args[0]->val_str(str)) ||
+ file_name->append('\0')
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|| !(current_thd->security_ctx->master_access & FILE_ACL)
#endif
)
goto err;
- (void) fn_format(path, file_name->c_ptr(), mysql_real_data_home, "",
+ (void) fn_format(path, file_name->ptr(), mysql_real_data_home, "",
MY_RELATIVE_PATH | MY_UNPACK_FILENAME);
/* Read only allowed from within dir specified by secure_file_priv */
@@ -2858,7 +2859,7 @@ String *Item_load_file::val_str(String *
}
if (tmp_value.alloc(stat_info.st_size))
goto err;
- if ((file = my_open(file_name->c_ptr(), O_RDONLY, MYF(0))) < 0)
+ if ((file = my_open(file_name->ptr(), O_RDONLY, MYF(0))) < 0)
goto err;
if (my_read(file, (byte*) tmp_value.ptr(), stat_info.st_size, MYF(MY_NABP)))
{
Attachment: [text/bzr-bundle] bzr/ramil@mysql.com-20090512061243-10gqa2yedv6dz6tm.bundle
| Thread |
|---|
| • bzr commit into mysql-5.0-bugteam branch (ramil:2737) Bug#44774 | Ramil Kalimullin | 12 May |