1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-23 10:29:58 +01:00

common,w32: Improve HKCU->HKLM fallback

* common/w32-reg.c (read_w32_registry_string): Add another fallback.
--

We use the same method in gpgme and libgpg-error since 2017 - should
be done here as well.  Thus the fallback also happens if the key
exists but not the actual entry.
This commit is contained in:
Werner Koch 2022-01-12 14:48:55 +01:00
parent bf4cf04a54
commit 96db487a4d
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -160,8 +160,18 @@ read_w32_registry_string (const char *root, const char *dir, const char *name)
}
nbytes = 1;
if (RegQueryValueEx( key_handle, name, 0, NULL, NULL, &nbytes ) )
goto leave;
if (RegQueryValueEx (key_handle, name, 0, NULL, NULL, &nbytes))
{
if (root)
goto leave;
/* Try to fallback to HKLM also for a missing value. */
RegCloseKey (key_handle);
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, dir, 0, KEY_READ, &key_handle))
return NULL; /* Nope. */
if (RegQueryValueEx (key_handle, name, 0, NULL, NULL, &nbytes))
goto leave;
}
result = xtrymalloc ((n1=nbytes+1));
if (!result)
goto leave;