X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=windows%2Fwinstore.c;h=6944849658f5ff185df52bfee39e239a6dce31e0;hb=21101c7397e460933635a7bfed813864fc4f88fe;hp=47fef678cdc126fe77abaca6c3cca2e9ddd6e722;hpb=b99bec3b02d79c6902f50cfa616eebaee43536f6;p=PuTTY.git diff --git a/windows/winstore.c b/windows/winstore.c index 47fef678..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; @@ -749,7 +764,7 @@ static int transform_jumplist_registry /* * Either return or free the result. */ - if (out) + if (out && ret == ERROR_SUCCESS) *out = old_value; else sfree(old_value); @@ -782,7 +797,7 @@ char *get_jumplist_registry_entries (void) { char *list_value; - if (transform_jumplist_registry(NULL,NULL,&list_value) != ERROR_SUCCESS) { + if (transform_jumplist_registry(NULL,NULL,&list_value) != JUMPLISTREG_OK) { list_value = snewn(2, char); *list_value = '\0'; *(list_value + 1) = '\0';