mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 09:58:01 +00:00
Jordan Russell's patch (again): a couple of registry read operations
were using RegCreateKey instead of RegOpenKey by mistake. This also required a fix in settings.c to deal gracefully with a NULL return from enum_settings_start() - since the use of RCK had caused this never to happen, the code path had never been tested. [originally from svn r1516]
This commit is contained in:
parent
7423036505
commit
66a53cd2c0
29
settings.c
29
settings.c
@ -565,24 +565,23 @@ void get_sesslist(int allocate)
|
|||||||
|
|
||||||
if (allocate) {
|
if (allocate) {
|
||||||
|
|
||||||
if ((handle = enum_settings_start()) == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
buflen = bufsize = 0;
|
buflen = bufsize = 0;
|
||||||
buffer = NULL;
|
buffer = NULL;
|
||||||
do {
|
if ((handle = enum_settings_start())) {
|
||||||
ret = enum_settings_next(handle, otherbuf, sizeof(otherbuf));
|
do {
|
||||||
if (ret) {
|
ret = enum_settings_next(handle, otherbuf, sizeof(otherbuf));
|
||||||
int len = strlen(otherbuf) + 1;
|
if (ret) {
|
||||||
if (bufsize < buflen + len) {
|
int len = strlen(otherbuf) + 1;
|
||||||
bufsize = buflen + len + 2048;
|
if (bufsize < buflen + len) {
|
||||||
buffer = srealloc(buffer, bufsize);
|
bufsize = buflen + len + 2048;
|
||||||
|
buffer = srealloc(buffer, bufsize);
|
||||||
|
}
|
||||||
|
strcpy(buffer + buflen, otherbuf);
|
||||||
|
buflen += strlen(buffer + buflen) + 1;
|
||||||
}
|
}
|
||||||
strcpy(buffer + buflen, otherbuf);
|
} while (ret);
|
||||||
buflen += strlen(buffer + buflen) + 1;
|
enum_settings_finish(handle);
|
||||||
}
|
}
|
||||||
} while (ret);
|
|
||||||
enum_settings_finish(handle);
|
|
||||||
buffer = srealloc(buffer, buflen + 1);
|
buffer = srealloc(buffer, buflen + 1);
|
||||||
buffer[buflen] = '\0';
|
buffer[buflen] = '\0';
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ void *enum_settings_start(void)
|
|||||||
struct enumsettings *ret;
|
struct enumsettings *ret;
|
||||||
HKEY key;
|
HKEY key;
|
||||||
|
|
||||||
if (RegCreateKey(HKEY_CURRENT_USER, puttystr, &key) != ERROR_SUCCESS)
|
if (RegOpenKey(HKEY_CURRENT_USER, puttystr, &key) != ERROR_SUCCESS)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ret = smalloc(sizeof(*ret));
|
ret = smalloc(sizeof(*ret));
|
||||||
@ -246,8 +246,8 @@ int verify_host_key(char *hostname, int port, char *keytype, char *key)
|
|||||||
|
|
||||||
hostkey_regname(regname, hostname, port, keytype);
|
hostkey_regname(regname, hostname, port, keytype);
|
||||||
|
|
||||||
if (RegCreateKey(HKEY_CURRENT_USER, PUTTY_REG_POS "\\SshHostKeys",
|
if (RegOpenKey(HKEY_CURRENT_USER, PUTTY_REG_POS "\\SshHostKeys",
|
||||||
&rkey) != ERROR_SUCCESS)
|
&rkey) != ERROR_SUCCESS)
|
||||||
return 1; /* key does not exist in registry */
|
return 1; /* key does not exist in registry */
|
||||||
|
|
||||||
readlen = len;
|
readlen = len;
|
||||||
|
Loading…
Reference in New Issue
Block a user