Skip to content

Commit

Permalink
MDEV-33659 Fix crash in kdf() without parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
andremralves authored and LinuxJedi committed Apr 11, 2024
1 parent 9d806a0 commit 435a10e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions mysql-test/main/func_kdf.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
7 changes: 7 additions & 0 deletions mysql-test/main/func_kdf.test
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
Expand Down
6 changes: 5 additions & 1 deletion sql/item_create.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 435a10e

Please sign in to comment.