summaryrefslogtreecommitdiff
path: root/sql/item_strfunc.h
diff options
context:
space:
mode:
authorGeorgi Kodinov <joro@sun.com>2009-04-17 18:52:57 +0300
committerGeorgi Kodinov <joro@sun.com>2009-04-17 18:52:57 +0300
commit08044795697dfd588841f9bacf589a4eeeff2431 (patch)
tree1a103f41199af1702db6e3d6d01f1ada092c387d /sql/item_strfunc.h
parentff923cc82d23f9806834a2411150e32d30b9f4d9 (diff)
downloadmariadb-git-08044795697dfd588841f9bacf589a4eeeff2431.tar.gz
Bug #35087: Inserting duplicate values at one time with DES_ENCRYPT leads
to wrong results 3 problems found with DES_ENCRYPT/DES_DECRYPT : 1. The max length was not calculated properly. Fixed in fix_length_and_dec() 2. DES_ENCRYPT had a side effect of sometimes reallocating and changing the value of its argument. Fixed by explicitly pre-allocating the necessary space to pad the argument with trailing '*' (stars) when calculating the DES digest. 3. in DES_ENCRYPT the string buffer for the result value was not reallocated to the correct size and only string length was assigned to it. Fixed by making sure there's enough space to hold the result.
Diffstat (limited to 'sql/item_strfunc.h')
-rw-r--r--sql/item_strfunc.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index 9794a092648..1c5346ab074 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -306,13 +306,17 @@ public:
class Item_func_des_encrypt :public Item_str_func
{
- String tmp_value;
+ String tmp_value,tmp_arg;
public:
Item_func_des_encrypt(Item *a) :Item_str_func(a) {}
Item_func_des_encrypt(Item *a, Item *b): Item_str_func(a,b) {}
String *val_str(String *);
void fix_length_and_dec()
- { maybe_null=1; max_length = args[0]->max_length+8; }
+ {
+ maybe_null=1;
+ /* 9 = MAX ((8- (arg_len % 8)) + 1) */
+ max_length = args[0]->max_length + 9;
+ }
const char *func_name() const { return "des_encrypt"; }
};
@@ -323,7 +327,12 @@ public:
Item_func_des_decrypt(Item *a) :Item_str_func(a) {}
Item_func_des_decrypt(Item *a, Item *b): Item_str_func(a,b) {}
String *val_str(String *);
- void fix_length_and_dec() { maybe_null=1; max_length = args[0]->max_length; }
+ void fix_length_and_dec()
+ {
+ maybe_null=1;
+ /* 9 = MAX ((8- (arg_len % 8)) + 1) */
+ max_length = args[0]->max_length - 9;
+ }
const char *func_name() const { return "des_decrypt"; }
};