Commit ebe83d56 authored by Mounir IDRASSI's avatar Mounir IDRASSI Committed by Alexandre Julliard

crypt32: Fix crash in CertGetCertificateContextProperty when querying length of a hash property.

parent ed79ddab
......@@ -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 };
......
......@@ -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 };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment