X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=windows%2Fwinstore.c;h=6944849658f5ff185df52bfee39e239a6dce31e0;hb=9f9d72ec58642e91b4f93ee4405a8086ee2fb2f0;hp=ce5dae61da56070ad8676d309cffd425954e7099;hpb=f9f93584c29d9e327985d3c695b87f9b981de7be;p=PuTTY.git diff --git a/windows/winstore.c b/windows/winstore.c index ce5dae61..69448496 100644 --- a/windows/winstore.c +++ b/windows/winstore.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "putty.h" #include "storage.h" @@ -152,7 +153,7 @@ void *open_settings_r(const char *sessionname) char *read_setting_s(void *handle, const char *key) { - DWORD type, size; + DWORD type, allocsize, size; char *ret; if (!handle) @@ -164,13 +165,17 @@ char *read_setting_s(void *handle, const char *key) type != REG_SZ) return NULL; - ret = snewn(size+1, char); + allocsize = size+1; /* allow for an extra NUL if needed */ + ret = snewn(allocsize, char); if (RegQueryValueEx((HKEY) handle, key, 0, &type, ret, &size) != ERROR_SUCCESS || type != REG_SZ) { sfree(ret); return NULL; } + assert(size < allocsize); + ret[size] = '\0'; /* add an extra NUL in case RegQueryValueEx + * didn't supply one */ return ret; } @@ -449,6 +454,16 @@ int verify_host_key(const char *hostname, int port, return 0; /* key matched OK in registry */ } +int have_ssh_host_key(const char *hostname, int port, + const char *keytype) +{ + /* + * If we have a host key, verify_host_key will return 0 or 2. + * If we don't have one, it'll return 1. + */ + return verify_host_key(hostname, port, keytype, "") != 1; +} + void store_host_key(const char *hostname, int port, const char *keytype, const char *key) { @@ -642,7 +657,7 @@ static int transform_jumplist_registry int ret; HKEY pjumplist_key, psettings_tmp; DWORD type; - int value_length; + DWORD value_length; char *old_value, *new_value; char *piterator_old, *piterator_new, *piterator_tmp;