diff options
author | Werner Koch <[email protected]> | 2022-01-12 13:48:55 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2022-01-12 13:48:55 +0000 |
commit | 96db487a4da5903b71c64edf7a0ee9c2e01a8762 (patch) | |
tree | 0f0882b8f114825f0732687e7648b2031ef4fd65 | |
parent | gpgtar: List and extract using extended headers. (diff) | |
download | gnupg-96db487a4da5903b71c64edf7a0ee9c2e01a8762.tar.gz gnupg-96db487a4da5903b71c64edf7a0ee9c2e01a8762.zip |
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.
-rw-r--r-- | common/w32-reg.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/common/w32-reg.c b/common/w32-reg.c index fda2d1cfa..816531fd5 100644 --- a/common/w32-reg.c +++ b/common/w32-reg.c @@ -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; |