Commit 041123ba authored by unknown's avatar unknown

Handle errors returned by system crypt() in ENCRYPT(). (Bug #13619)


mysql-test/r/func_crypt.result:
  Add new results
mysql-test/t/func_crypt.test:
  Add new regression test
sql/item_strfunc.cc:
  Handle NULL result from call to crypt().
parent 78f5997a
...@@ -92,3 +92,6 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -92,3 +92,6 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select password(_latin1'idkfa ') AS `password('idkfa ')`,old_password(_latin1'idkfa') AS `old_password('idkfa')` Note 1003 select password(_latin1'idkfa ') AS `password('idkfa ')`,old_password(_latin1'idkfa') AS `old_password('idkfa')`
select encrypt('1234','_.');
encrypt('1234','_.')
#
...@@ -49,4 +49,10 @@ select old_password(' i d k f a '); ...@@ -49,4 +49,10 @@ select old_password(' i d k f a ');
explain extended select password('idkfa '), old_password('idkfa'); explain extended select password('idkfa '), old_password('idkfa');
#
# Bug #13619: Crash on FreeBSD with salt like '_.'
#
--replace_column 1 #
select encrypt('1234','_.');
# End of 4.1 tests # End of 4.1 tests
...@@ -1497,7 +1497,13 @@ String *Item_func_encrypt::val_str(String *str) ...@@ -1497,7 +1497,13 @@ String *Item_func_encrypt::val_str(String *str)
salt_ptr= salt_str->c_ptr(); salt_ptr= salt_str->c_ptr();
} }
pthread_mutex_lock(&LOCK_crypt); pthread_mutex_lock(&LOCK_crypt);
char *tmp=crypt(res->c_ptr(),salt_ptr); char *tmp= crypt(res->c_ptr(),salt_ptr);
if (!tmp)
{
pthread_mutex_unlock(&LOCK_crypt);
null_value= 1;
return 0;
}
str->set(tmp,(uint) strlen(tmp),res->charset()); str->set(tmp,(uint) strlen(tmp),res->charset());
str->copy(); str->copy();
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