Module: wine Branch: master Commit: ebe83d561b990343db78728123ac828984494e78 URL: http://source.winehq.org/git/wine.git/?a=commit;h=ebe83d561b990343db78728123...
Author: Mounir IDRASSI mounir.idrassi@idrix.fr Date: Mon May 14 00:25:04 2007 +0200
crypt32: Fix crash in CertGetCertificateContextProperty when querying length of a hash property.
---
dlls/crypt32/cert.c | 2 +- dlls/crypt32/tests/cert.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/dlls/crypt32/cert.c b/dlls/crypt32/cert.c index 884c2da..3912447 100644 --- a/dlls/crypt32/cert.c +++ b/dlls/crypt32/cert.c @@ -158,7 +158,7 @@ static BOOL CertContext_GetHashProp(void *context, DWORD dwPropId, { BOOL ret = CryptHashCertificate(0, algID, 0, toHash, toHashLen, pvData, pcbData); - if (ret) + if (ret && pvData) { CRYPT_DATA_BLOB blob = { *pcbData, pvData };
diff --git a/dlls/crypt32/tests/cert.c b/dlls/crypt32/tests/cert.c index cdc6cfb..c9f7a0a 100644 --- a/dlls/crypt32/tests/cert.c +++ b/dlls/crypt32/tests/cert.c @@ -294,18 +294,25 @@ static void checkHash(const BYTE *data, DWORD dataLen, ALG_ID algID, BYTE hash[20] = { 0 }, hashProperty[20]; BOOL ret; DWORD size; + DWORD dwSizeWithNull;
memset(hash, 0, sizeof(hash)); memset(hashProperty, 0, sizeof(hashProperty)); size = sizeof(hash); ret = CryptHashCertificate(0, algID, 0, data, dataLen, hash, &size); ok(ret, "CryptHashCertificate failed: %08x\n", GetLastError()); + ret = CertGetCertificateContextProperty(context, propID, NULL, + &dwSizeWithNull); + ok(ret, "CertGetCertificateContextProperty failed: %08x\n", + GetLastError()); ret = CertGetCertificateContextProperty(context, propID, hashProperty, &size); ok(ret, "CertGetCertificateContextProperty failed: %08x\n", GetLastError()); ok(!memcmp(hash, hashProperty, size), "Unexpected hash for property %d\n", propID); + ok(size == dwSizeWithNull, "Unexpected length of hash for property: received %d instead of %d\n", + dwSizeWithNull,size); }
static WCHAR cspNameW[] = { 'W','i','n','e','C','r','y','p','t','T','e','m','p',0 };