Hans Leidekker : bcrypt: Clear magic bytes on destroy.
Alexandre Julliard
julliard at winehq.org
Mon Dec 17 15:36:39 CST 2018
Module: wine
Branch: master
Commit: 370ffa0d149d366cfcc9f544dd182b8b3592d708
URL: https://source.winehq.org/git/wine.git/?a=commit;h=370ffa0d149d366cfcc9f544dd182b8b3592d708
Author: Hans Leidekker <hans at codeweavers.com>
Date: Mon Dec 17 09:47:58 2018 +0100
bcrypt: Clear magic bytes on destroy.
Based on a patch by Steven Noonan.
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/bcrypt/bcrypt_main.c | 5 ++++-
dlls/bcrypt/tests/bcrypt.c | 15 +++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index 0c68a4f..c236491 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -214,6 +214,7 @@ NTSTATUS WINAPI BCryptCloseAlgorithmProvider( BCRYPT_ALG_HANDLE handle, DWORD fl
TRACE( "%p, %08x\n", handle, flags );
if (!alg || alg->hdr.magic != MAGIC_ALG) return STATUS_INVALID_HANDLE;
+ alg->hdr.magic = 0;
heap_free( alg );
return STATUS_SUCCESS;
}
@@ -672,7 +673,8 @@ NTSTATUS WINAPI BCryptDestroyHash( BCRYPT_HASH_HANDLE handle )
TRACE( "%p\n", handle );
- if (!hash || hash->hdr.magic != MAGIC_HASH) return STATUS_INVALID_HANDLE;
+ if (!hash || hash->hdr.magic != MAGIC_HASH) return STATUS_INVALID_PARAMETER;
+ hash->hdr.magic = 0;
heap_free( hash );
return STATUS_SUCCESS;
}
@@ -1265,6 +1267,7 @@ NTSTATUS WINAPI BCryptDestroyKey( BCRYPT_KEY_HANDLE handle )
TRACE( "%p\n", handle );
if (!key || key->hdr.magic != MAGIC_KEY) return STATUS_INVALID_HANDLE;
+ key->hdr.magic = 0;
return key_destroy( key );
}
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
index c3f8f3d..5240c3b 100644
--- a/dlls/bcrypt/tests/bcrypt.c
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -293,6 +293,12 @@ static void test_hash(const struct hash_test *test)
ret = pBCryptDestroyHash(hash);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+ ret = pBCryptDestroyHash(hash);
+ ok(ret == STATUS_INVALID_PARAMETER, "got %08x\n", ret);
+
+ ret = pBCryptDestroyHash(NULL);
+ ok(ret == STATUS_INVALID_PARAMETER, "got %08x\n", ret);
+
ret = pBCryptCloseAlgorithmProvider(alg, 0);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
}
@@ -1415,8 +1421,17 @@ static void test_BCryptDecrypt(void)
ok(ret == STATUS_INVALID_HANDLE, "got %08x\n", ret);
HeapFree(GetProcessHeap(), 0, buf);
+ ret = pBCryptDestroyKey(NULL);
+ ok(ret == STATUS_INVALID_HANDLE, "got %08x\n", ret);
+
ret = pBCryptCloseAlgorithmProvider(aes, 0);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+
+ ret = pBCryptCloseAlgorithmProvider(aes, 0);
+ ok(ret == STATUS_INVALID_HANDLE, "got %08x\n", ret);
+
+ ret = pBCryptCloseAlgorithmProvider(NULL, 0);
+ ok(ret == STATUS_INVALID_HANDLE, "got %08x\n", ret);
}
static void test_key_import_export(void)
More information about the wine-cvs
mailing list