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().
This commit is contained in:
parent
c27566aec5
commit
3b3fc01425
@ -2526,3 +2526,17 @@ h i
|
||||
31.12.2008 AAAAAA, aaaaaa
|
||||
DROP TABLE t1;
|
||||
End of 5.0 tests
|
||||
drop table if exists t1;
|
||||
create table t1(f1 tinyint default null)engine=myisam;
|
||||
insert into t1 values (-1),(null);
|
||||
explain select 1 as a from t1,(select decode(f1,f1) as b from t1) a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 Using join buffer
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 2
|
||||
explain select 1 as a from t1,(select encode(f1,f1) as b from t1) a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 Using join buffer
|
||||
2 DERIVED t1 ALL NULL NULL NULL NULL 2
|
||||
drop table t1;
|
||||
|
@ -1283,3 +1283,15 @@ SELECT DATE_FORMAT(c, GET_FORMAT(DATE, 'eur')) h, CONCAT(UPPER(aa),', ', aa) i F
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo End of 5.0 tests
|
||||
|
||||
#
|
||||
# Bug#44358 valgrind errors with decode() function
|
||||
#
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1(f1 tinyint default null)engine=myisam;
|
||||
insert into t1 values (-1),(null);
|
||||
explain select 1 as a from t1,(select decode(f1,f1) as b from t1) a;
|
||||
explain select 1 as a from t1,(select encode(f1,f1) as b from t1) a;
|
||||
drop table t1;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user