ADVAPI32: if a crypto provider has no signature, load it anyway
Mike McCormack
mike at codeweavers.com
Mon Nov 10 06:20:00 CST 2003
Hi,
Since we have our own rsabase.dll, and it has no signature data in the
registry, we should load it anyway until we figure out how to sign
builtin dlls...
Mike
ChangeLog:
* if a crypto provider has no signature, load it anyway
* check return codes of all registry access functions
-------------- next part --------------
Index: dlls/advapi32/crypt.c
===================================================================
RCS file: /home/wine/wine/dlls/advapi32/crypt.c,v
retrieving revision 1.29
diff -u -r1.29 crypt.c
--- dlls/advapi32/crypt.c 22 Oct 2003 03:04:30 -0000 1.29
+++ dlls/advapi32/crypt.c 10 Nov 2003 12:10:55 -0000
@@ -258,6 +258,7 @@
PSTR imagepath = NULL, keyname = NULL, provname = NULL, temp = NULL;
BYTE* signature;
DWORD keytype, type, len;
+ ULONG r;
TRACE("(%p, %s, %s, %ld, %08lx)\n", phProv, pszContainer,
pszProvider, dwProvType, dwFlags);
@@ -300,9 +301,10 @@
}
}
CRYPT_Free(keyname);
- RegQueryValueExA(key, "Name", NULL, &keytype, NULL, &len);
- if (!len || keytype != REG_SZ)
+ r = RegQueryValueExA(key, "Name", NULL, &keytype, NULL, &len);
+ if( r != ERROR_SUCCESS || !len || keytype != REG_SZ)
{
+ TRACE("error %ld at line %d\n", r, __LINE__);
RegCloseKey(key);
SetLastError(NTE_PROV_TYPE_ENTRY_BAD);
goto error;
@@ -313,7 +315,14 @@
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
goto error;
}
- RegQueryValueExA(key, "Name", NULL, NULL, provname, &len);
+ r = RegQueryValueExA(key, "Name", NULL, NULL, provname, &len);
+ if( r != ERROR_SUCCESS )
+ {
+ TRACE("error %ld at line %d\n", r, __LINE__);
+ RegCloseKey(key);
+ SetLastError(NTE_PROV_TYPE_ENTRY_BAD);
+ goto error;
+ }
RegCloseKey(key);
} else {
if ( !(provname = CRYPT_Alloc(strlen(pszProvider) +1)) )
@@ -328,17 +337,18 @@
if (RegOpenKeyA(HKEY_LOCAL_MACHINE, keyname, &key)) goto error;
CRYPT_Free(keyname);
len = sizeof(DWORD);
- RegQueryValueExA(key, "Type", NULL, NULL, (BYTE*)&type, &len);
- if (type != dwProvType)
+ r = RegQueryValueExA(key, "Type", NULL, NULL, (BYTE*)&type, &len);
+ if (r != ERROR_SUCCESS || type != dwProvType)
{
FIXME("Crypto provider has wrong type (%ld vs expected %ld).\n", type, dwProvType);
SetLastError(NTE_BAD_PROV_TYPE);
goto error;
}
- RegQueryValueExA(key, "Image Path", NULL, &keytype, NULL, &len);
- if (keytype != REG_SZ)
+ r = RegQueryValueExA(key, "Image Path", NULL, &keytype, NULL, &len);
+ if ( r != ERROR_SUCCESS || keytype != REG_SZ)
{
+ TRACE("error %ld at line %d\n", r, __LINE__);
RegCloseKey(key);
SetLastError(NTE_PROV_TYPE_ENTRY_BAD);
goto error;
@@ -349,22 +359,45 @@
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
goto error;
}
- RegQueryValueExA(key, "Image Path", NULL, NULL, temp, &len);
-
- RegQueryValueExA(key, "Signature", NULL, &keytype, NULL, &len);
- if (keytype != REG_BINARY)
+ r = RegQueryValueExA(key, "Image Path", NULL, NULL, temp, &len);
+ if( r != ERROR_SUCCESS )
{
+ TRACE("error %ld at line %d\n", r, __LINE__);
RegCloseKey(key);
SetLastError(NTE_PROV_TYPE_ENTRY_BAD);
goto error;
}
- if (!(signature = CRYPT_Alloc(len)))
+
+ r = RegQueryValueExA(key, "Signature", NULL, &keytype, NULL, &len);
+ if ( r == ERROR_SUCCESS )
{
- RegCloseKey(key);
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- goto error;
+ if ( r != ERROR_SUCCESS || keytype != REG_BINARY)
+ {
+ TRACE("error %ld at line %d\n", r, __LINE__);
+ RegCloseKey(key);
+ SetLastError(NTE_PROV_TYPE_ENTRY_BAD);
+ goto error;
+ }
+ if (!(signature = CRYPT_Alloc(len)))
+ {
+ RegCloseKey(key);
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ goto error;
+ }
+ r = RegQueryValueExA(key, "Signature", NULL, NULL, signature, &len);
+ if ( r != ERROR_SUCCESS )
+ {
+ TRACE("error %ld at line %d\n", r, __LINE__);
+ RegCloseKey(key);
+ SetLastError(NTE_PROV_TYPE_ENTRY_BAD);
+ goto error;
+ }
+ }
+ else
+ {
+ FIXME("Crypto provider has no signature... probably a builtin\n");
+ signature = NULL;
}
- RegQueryValueExA(key, "Signature", NULL, NULL, signature, &len);
RegCloseKey(key);
len = ExpandEnvironmentStringsA(temp, NULL, 0);
@@ -381,7 +414,7 @@
goto error;
}
- if (!CRYPT_VerifyImage(imagepath, signature))
+ if (signature && !CRYPT_VerifyImage(imagepath, signature))
{
CRYPT_Free(signature);
SetLastError(NTE_SIGNATURE_FILE_BAD);
@@ -390,7 +423,8 @@
pProv = CRYPT_LoadProvider(imagepath);
CRYPT_Free(temp);
CRYPT_Free(imagepath);
- CRYPT_Free(signature);
+ if( signature )
+ CRYPT_Free(signature);
if (!pProv) {
FIXME("Could not load crypto provider from DLL %s\n", debugstr_a(imagepath));
/* CRYPT_LoadProvider calls SetLastError */
More information about the wine-patches
mailing list