Bug in Advapi32: CryptEnumProviderTypesA and CryptEnumProvidersA
Mounir IDRASSI
mounir.idrassi at idrix.fr
Wed May 2 13:33:15 CDT 2007
Hi,
During our tests of wine with our cryptographic suite, we have found a
bug in the functions CryptEnumProviderTypesA and CryptEnumProvidersA in
advapi32 dll: In case of failure, they both report a wrong last error
through GetLastError.
We have found and corrected the source of the bug: They both call their
wide-char counterpart but they don't test the success of this call.
The correction is simple: add an if statement and return immediately in
case of error. I have attached a small patch with our correction.
Should we fill a bugzilla report before submitting the patch?
Thanks.
Mounir IDRASSI
IDRIX - Cryptography and IT Security Experts
http://www.idrix.fr
-------------- next part --------------
>From ab7323952138e725700ded1bad4afd17e42717e7 Mon Sep 17 00:00:00 2001
From: Mounir IDRASSI <mounir.idrassi at idrix.fr>
Date: Wed, 2 May 2007 20:20:59 +0200
Subject: Correct bug in CryptEnumProviderTypesA and CryptEnumProvidersA: They report wrong last error in case of failure
---
dlls/advapi32/crypt.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/dlls/advapi32/crypt.c b/dlls/advapi32/crypt.c
index 1fd16c3..a7273b9 100644
--- a/dlls/advapi32/crypt.c
+++ b/dlls/advapi32/crypt.c
@@ -1139,7 +1139,8 @@ BOOL WINAPI CryptEnumProvidersA (DWORD dwIndex, DWORD *pdwReserved,
TRACE("(%d, %p, %08x, %p, %p, %p)\n", dwIndex, pdwReserved, dwFlags,
pdwProvType, pszProvName, pcbProvName);
- CryptEnumProvidersW(dwIndex, pdwReserved, dwFlags, pdwProvType, NULL, &strlen);
+ if(!CryptEnumProvidersW(dwIndex, pdwReserved, dwFlags, pdwProvType, NULL, &strlen))
+ return FALSE;
if ( pszProvName && !(str = CRYPT_Alloc(strlen)) )
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
@@ -1267,7 +1268,8 @@ BOOL WINAPI CryptEnumProviderTypesA (DWORD dwIndex, DWORD *pdwReserved,
TRACE("(%d, %p, %08x, %p, %p, %p)\n", dwIndex, pdwReserved, dwFlags,
pdwProvType, pszTypeName, pcbTypeName);
- CryptEnumProviderTypesW(dwIndex, pdwReserved, dwFlags, pdwProvType, NULL, &strlen);
+ if(!CryptEnumProviderTypesW(dwIndex, pdwReserved, dwFlags, pdwProvType, NULL, &strlen))
+ return FALSE;
if ( pszTypeName && !(str = CRYPT_Alloc(strlen)) )
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
--
1.4.4.2
More information about the wine-devel
mailing list