summaryrefslogtreecommitdiff
path: root/sql/item_strfunc.cc
diff options
context:
space:
mode:
authorRamil Kalimullin <ramil@mysql.com>2009-05-12 13:18:27 +0500
committerRamil Kalimullin <ramil@mysql.com>2009-05-12 13:18:27 +0500
commit8b9084eff4a7142192bb1ff82c2e982ed546a78c (patch)
treeea48c0530946dca7bf2c0b1e27eefecc33b627f6 /sql/item_strfunc.cc
parentd615a11bd5d3572f51c6341c02338e7c742e29c0 (diff)
downloadmariadb-git-8b9084eff4a7142192bb1ff82c2e982ed546a78c.tar.gz
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 - passing a file name to fn_format(), file_name->c_ptr() replaced with file_name->c_ptr_safe() to ensure we have a trailing '\0'.
Diffstat (limited to 'sql/item_strfunc.cc')
-rw-r--r--sql/item_strfunc.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 4640929b2bf..bc2dcb9c61b 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -2832,7 +2832,7 @@ String *Item_load_file::val_str(String *str)
)
goto err;
- (void) fn_format(path, file_name->c_ptr(), mysql_real_data_home, "",
+ (void) fn_format(path, file_name->c_ptr_safe(), mysql_real_data_home, "",
MY_RELATIVE_PATH | MY_UNPACK_FILENAME);
/* Read only allowed from within dir specified by secure_file_priv */
@@ -2858,7 +2858,7 @@ String *Item_load_file::val_str(String *str)
}
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)))
{