MDEV-33659 Fix crash in kdf() without parameters

This commit is contained in:
Andre Alves 2024-03-25 13:55:45 -03:00 committed by Andrew Hutchings
commit 435a10e4dc
3 changed files with 17 additions and 1 deletions

View file

@ -154,5 +154,10 @@ NULL
Warnings:
Warning 3047 Invalid argument error: 65537 in function kdf.
#
# MDEV-33659 Test kdf() without parameters
#
select kdf();
ERROR 42000: Incorrect parameter count in the call to native function 'kdf'
#
# End of 11.3 tests
#

View file

@ -51,6 +51,13 @@ select length(kdf('foo', 'bar', 100, 'pbkdf2_hmac', 32768));
select length(kdf('foo', 'bar', 100, 'pbkdf2_hmac', 65536));
select length(kdf('foo', 'bar', 100, 'pbkdf2_hmac', 65537));
--echo #
--echo # MDEV-33659 Test kdf() without parameters
--echo #
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
select kdf();
--echo #
--echo # End of 11.3 tests
--echo #

View file

@ -3229,8 +3229,12 @@ Item*
Create_func_kdf::create_native(THD *thd, const LEX_CSTRING *name,
List<Item> *item_list)
{
uint arg_count= item_list->elements;
Item *a[5];
uint arg_count= 0;
if (item_list != NULL)
arg_count= item_list->elements;
for (uint i=0; i < MY_MIN(array_elements(a), arg_count); i++)
a[i]= item_list->pop();
switch (arg_count)