Commit 0c65370a authored by Sergey Glukhov's avatar Sergey Glukhov

Bug#44365 valgrind warnings with encrypt() function

replaced String->c_ptr() with String->c_ptr_safe()
parent 3b3fc014
...@@ -183,3 +183,15 @@ id select_type table type possible_keys key key_len ref rows filtered Extra ...@@ -183,3 +183,15 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select des_decrypt(des_encrypt('hello',4),'password2') AS `des_decrypt(des_encrypt("hello",4),'password2')`,des_decrypt(des_encrypt('hello','hidden')) AS `des_decrypt(des_encrypt("hello","hidden"))` Note 1003 select des_decrypt(des_encrypt('hello',4),'password2') AS `des_decrypt(des_encrypt("hello",4),'password2')`,des_decrypt(des_encrypt('hello','hidden')) AS `des_decrypt(des_encrypt("hello","hidden"))`
drop table if exists t1;
create table t1 (f1 smallint(6) default null, f2 mediumtext character set utf8)
engine=myisam default charset=latin1;
insert into t1 values (null,'contraction\'s');
insert into t1 values (-15818,'requirement\'s');
select encrypt(f1,f2) as a from t1,(select encrypt(f1,f2) as b from t1) a;
a
NULL
re3VF.eOzS/lg
NULL
re3VF.eOzS/lg
drop table t1;
...@@ -88,3 +88,16 @@ select hex(des_decrypt(des_encrypt("hello","hidden"))); ...@@ -88,3 +88,16 @@ select hex(des_decrypt(des_encrypt("hello","hidden")));
explain extended select des_decrypt(des_encrypt("hello",4),'password2'), des_decrypt(des_encrypt("hello","hidden")); explain extended select des_decrypt(des_encrypt("hello",4),'password2'), des_decrypt(des_encrypt("hello","hidden"));
# End of 4.1 tests # End of 4.1 tests
#
# Bug#44365 valgrind warnings with encrypt() function
#
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1 (f1 smallint(6) default null, f2 mediumtext character set utf8)
engine=myisam default charset=latin1;
insert into t1 values (null,'contraction\'s');
insert into t1 values (-15818,'requirement\'s');
select encrypt(f1,f2) as a from t1,(select encrypt(f1,f2) as b from t1) a;
drop table t1;
...@@ -1693,10 +1693,10 @@ String *Item_func_encrypt::val_str(String *str) ...@@ -1693,10 +1693,10 @@ String *Item_func_encrypt::val_str(String *str)
String *salt_str=args[1]->val_str(&tmp_value); String *salt_str=args[1]->val_str(&tmp_value);
if ((null_value= (args[1]->null_value || salt_str->length() < 2))) if ((null_value= (args[1]->null_value || salt_str->length() < 2)))
return 0; return 0;
salt_ptr= salt_str->c_ptr(); salt_ptr= salt_str->c_ptr_safe();
} }
pthread_mutex_lock(&LOCK_crypt); pthread_mutex_lock(&LOCK_crypt);
char *tmp= crypt(res->c_ptr(),salt_ptr); char *tmp= crypt(res->c_ptr_safe(),salt_ptr);
if (!tmp) if (!tmp)
{ {
pthread_mutex_unlock(&LOCK_crypt); pthread_mutex_unlock(&LOCK_crypt);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment