summaryrefslogtreecommitdiff
path: root/sql/item_strfunc.cc
diff options
context:
space:
mode:
authorunknown <jimw@mysql.com>2005-10-06 16:15:53 -0700
committerunknown <jimw@mysql.com>2005-10-06 16:15:53 -0700
commit041123bade5372483d387a724d22a8f7e06d0645 (patch)
tree693fd4dac7cc4dc26e3cfcb8510751307ebd2e19 /sql/item_strfunc.cc
parent78f5997adef773dfd5b05f6921b5da8066067c37 (diff)
downloadmariadb-git-041123bade5372483d387a724d22a8f7e06d0645.tar.gz
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().
Diffstat (limited to 'sql/item_strfunc.cc')
-rw-r--r--sql/item_strfunc.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 6962ba7c4ac..6ca6ce62c54 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1497,7 +1497,13 @@ String *Item_func_encrypt::val_str(String *str)
salt_ptr= salt_str->c_ptr();
}
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->copy();
pthread_mutex_unlock(&LOCK_crypt);