bcrypt: Fix array index in BCryptEnumAlgorithms().
Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
807d368f1d
commit
40306db341
|
@ -147,7 +147,7 @@ NTSTATUS WINAPI BCryptEnumAlgorithms( ULONG type, ULONG *ret_count, BCRYPT_ALGOR
|
||||||
BCRYPT_SIGNATURE_OPERATION |\
|
BCRYPT_SIGNATURE_OPERATION |\
|
||||||
BCRYPT_RNG_OPERATION;
|
BCRYPT_RNG_OPERATION;
|
||||||
BCRYPT_ALGORITHM_IDENTIFIER *list;
|
BCRYPT_ALGORITHM_IDENTIFIER *list;
|
||||||
ULONG i, count = 0;
|
ULONG i, j, count = 0;
|
||||||
|
|
||||||
TRACE( "%#lx, %p, %p, %#lx\n", type, ret_count, ret_list, flags );
|
TRACE( "%#lx, %p, %p, %#lx\n", type, ret_count, ret_list, flags );
|
||||||
|
|
||||||
|
@ -160,12 +160,13 @@ NTSTATUS WINAPI BCryptEnumAlgorithms( ULONG type, ULONG *ret_count, BCRYPT_ALGOR
|
||||||
|
|
||||||
if (!(list = malloc( count * sizeof(*list) ))) return STATUS_NO_MEMORY;
|
if (!(list = malloc( count * sizeof(*list) ))) return STATUS_NO_MEMORY;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE( builtin_algorithms ); i++)
|
for (i = 0, j = 0; i < ARRAY_SIZE( builtin_algorithms ); i++)
|
||||||
{
|
{
|
||||||
if (!match_operation_type( type, builtin_algorithms[i].class )) continue;
|
if (!match_operation_type( type, builtin_algorithms[i].class )) continue;
|
||||||
list[i].pszName = (WCHAR *)builtin_algorithms[i].name;
|
list[j].pszName = (WCHAR *)builtin_algorithms[i].name;
|
||||||
list[i].dwClass = builtin_algorithms[i].class;
|
list[j].dwClass = builtin_algorithms[i].class;
|
||||||
list[i].dwFlags = 0;
|
list[j].dwFlags = 0;
|
||||||
|
j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ret_count = count;
|
*ret_count = count;
|
||||||
|
|
|
@ -2668,7 +2668,7 @@ static void test_BCryptEnumAlgorithms(void)
|
||||||
{
|
{
|
||||||
BCRYPT_ALGORITHM_IDENTIFIER *list;
|
BCRYPT_ALGORITHM_IDENTIFIER *list;
|
||||||
NTSTATUS ret;
|
NTSTATUS ret;
|
||||||
ULONG count;
|
ULONG count, op;
|
||||||
|
|
||||||
ret = BCryptEnumAlgorithms(0, NULL, NULL, 0);
|
ret = BCryptEnumAlgorithms(0, NULL, NULL, 0);
|
||||||
ok(ret == STATUS_INVALID_PARAMETER, "got %#lx\n", ret);
|
ok(ret == STATUS_INVALID_PARAMETER, "got %#lx\n", ret);
|
||||||
|
@ -2689,6 +2689,16 @@ static void test_BCryptEnumAlgorithms(void)
|
||||||
ok(list != NULL, "NULL list\n");
|
ok(list != NULL, "NULL list\n");
|
||||||
ok(count, "got %lu\n", count);
|
ok(count, "got %lu\n", count);
|
||||||
BCryptFreeBuffer( list );
|
BCryptFreeBuffer( list );
|
||||||
|
|
||||||
|
op = BCRYPT_CIPHER_OPERATION | BCRYPT_ASYMMETRIC_ENCRYPTION_OPERATION | BCRYPT_SIGNATURE_OPERATION |
|
||||||
|
BCRYPT_SECRET_AGREEMENT_OPERATION;
|
||||||
|
count = 0;
|
||||||
|
list = NULL;
|
||||||
|
ret = BCryptEnumAlgorithms(op, &count, &list, 0);
|
||||||
|
ok(!ret, "got %#lx\n", ret);
|
||||||
|
ok(list != NULL, "NULL list\n");
|
||||||
|
ok(count, "got %lu\n", count);
|
||||||
|
BCryptFreeBuffer( list );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_aes_vector(void)
|
static void test_aes_vector(void)
|
||||||
|
|
Loading…
Reference in New Issue