diff options
author | Sergey Glukhov <Sergey.Glukhov@sun.com> | 2009-04-23 12:43:42 +0500 |
---|---|---|
committer | Sergey Glukhov <Sergey.Glukhov@sun.com> | 2009-04-23 12:43:42 +0500 |
commit | 5f9e40a5f8a469d87fb41002c18f3a41e9c4d6b3 (patch) | |
tree | 298f925620b41190de3964ef5aeb3d4c2359c97c /sql | |
parent | e0526914b6acb91f8cf15bd536ad40e226158d1b (diff) | |
download | mariadb-git-5f9e40a5f8a469d87fb41002c18f3a41e9c4d6b3.tar.gz |
Bug#44358 valgrind errors with decode() function
The warning happens because string argument is not zero ended.
The fix is to add new parameter 'length' to SQL_CRYPT() and
use ptr() instead of c_ptr().
mysql-test/r/func_str.result:
test result
mysql-test/t/func_str.test:
test case
sql/item_strfunc.cc:
Added new parameter 'length' to SQL_CRYPT
sql/sql_crypt.cc:
Added new parameter 'length' to SQL_CRYPT
sql/sql_crypt.h:
Added new parameter 'length' to SQL_CRYPT
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_strfunc.cc | 4 | ||||
-rw-r--r-- | sql/sql_crypt.cc | 4 | ||||
-rw-r--r-- | sql/sql_crypt.h | 2 |
3 files changed, 5 insertions, 5 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 5a8b1c6493c..5bb561fc1a9 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1742,7 +1742,7 @@ String *Item_func_encode::val_str(String *str) null_value=0; res=copy_if_not_alloced(str,res,res->length()); - SQL_CRYPT sql_crypt(password->ptr()); + SQL_CRYPT sql_crypt(password->ptr(), password->length()); sql_crypt.init(); sql_crypt.encode((char*) res->ptr(),res->length()); res->set_charset(&my_charset_bin); @@ -1771,7 +1771,7 @@ String *Item_func_decode::val_str(String *str) null_value=0; res=copy_if_not_alloced(str,res,res->length()); - SQL_CRYPT sql_crypt(password->ptr()); + SQL_CRYPT sql_crypt(password->ptr(), password->length()); sql_crypt.init(); sql_crypt.decode((char*) res->ptr(),res->length()); return res; diff --git a/sql/sql_crypt.cc b/sql/sql_crypt.cc index aa21d429d90..c4f93cc2a33 100644 --- a/sql/sql_crypt.cc +++ b/sql/sql_crypt.cc @@ -28,10 +28,10 @@ #include "mysql_priv.h" -SQL_CRYPT::SQL_CRYPT(const char *password) +SQL_CRYPT::SQL_CRYPT(const char *password, uint length) { ulong rand_nr[2]; - hash_password(rand_nr,password, (uint) strlen(password)); + hash_password(rand_nr,password, length); crypt_init(rand_nr); } diff --git a/sql/sql_crypt.h b/sql/sql_crypt.h index f3db9adde25..a5a6bee8a58 100644 --- a/sql/sql_crypt.h +++ b/sql/sql_crypt.h @@ -25,7 +25,7 @@ class SQL_CRYPT :public Sql_alloc uint shift; void crypt_init(ulong *seed); public: - SQL_CRYPT(const char *seed); + SQL_CRYPT(const char *seed, uint length); SQL_CRYPT(ulong *seed) { crypt_init(seed); |