crypt32: Fix crash in CertGetCertificateContextProperty when querying length of a hash property.
This commit is contained in:
parent
ed79ddab1d
commit
ebe83d561b
|
@ -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 };
|
||||
|
|
Loading…
Reference in New Issue