fusion: Handle DWORD-sized blob indices when loading the public key.

This commit is contained in:
Hans Leidekker 2012-05-23 13:05:14 +02:00 committed by Alexandre Julliard
parent 0b82e28401
commit 7c06862c52
1 changed files with 12 additions and 7 deletions

View File

@ -825,23 +825,22 @@ PEKIND assembly_get_architecture(ASSEMBLY *assembly)
return peI386; /* x86 assembly */ return peI386; /* x86 assembly */
} }
static BYTE *assembly_get_blob(ASSEMBLY *assembly, WORD index, ULONG *size) static BYTE *assembly_get_blob(ASSEMBLY *assembly, DWORD index, ULONG *size)
{ {
return GetData(&assembly->blobs[index], size); return GetData(&assembly->blobs[index], size);
} }
HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPWSTR *token) HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPWSTR *token)
{ {
ASSEMBLYTABLE *asmtbl;
ULONG i, size; ULONG i, size;
LONG offset; LONG offset;
BYTE *hashdata; BYTE *hashdata, *pubkey, *ptr;
HCRYPTPROV crypt; HCRYPTPROV crypt;
HCRYPTHASH hash; HCRYPTHASH hash;
BYTE *pubkey;
BYTE tokbytes[BYTES_PER_TOKEN]; BYTE tokbytes[BYTES_PER_TOKEN];
HRESULT hr = E_FAIL; HRESULT hr = E_FAIL;
LPWSTR tok; LPWSTR tok;
DWORD idx;
*token = NULL; *token = NULL;
@ -849,11 +848,17 @@ HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPWSTR *token)
if (offset == -1) if (offset == -1)
return E_FAIL; return E_FAIL;
asmtbl = assembly_data_offset(assembly, offset); ptr = assembly_data_offset(assembly, offset);
if (!asmtbl) if (!ptr)
return E_FAIL; return E_FAIL;
pubkey = assembly_get_blob(assembly, asmtbl->PublicKey, &size); ptr += FIELD_OFFSET(ASSEMBLYTABLE, PublicKey);
if (assembly->blobsz == sizeof(DWORD))
idx = *(DWORD *)ptr;
else
idx = *(WORD *)ptr;
pubkey = assembly_get_blob(assembly, idx, &size);
if (!CryptAcquireContextA(&crypt, NULL, NULL, PROV_RSA_FULL, if (!CryptAcquireContextA(&crypt, NULL, NULL, PROV_RSA_FULL,
CRYPT_VERIFYCONTEXT)) CRYPT_VERIFYCONTEXT))