X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/a9dc49af0a2d35e897d1e4db25c4465667f5f6e3..54018d95d47e4aff427c4e76f2d952c063ae077b:/windows/winpgen.c diff --git a/windows/winpgen.c b/windows/winpgen.c index 7ba88d2a..eac66dec 100644 --- a/windows/winpgen.c +++ b/windows/winpgen.c @@ -21,8 +21,6 @@ #define DEFAULT_KEYSIZE 1024 -static int requested_help; - static char *cmdline_keyfile = NULL; /* @@ -198,11 +196,6 @@ static int prompt_keyfile(HWND hwnd, char *dlgtitle, { OPENFILENAME of; memset(&of, 0, sizeof(of)); -#ifdef OPENFILENAME_SIZE_VERSION_400 - of.lStructSize = OPENFILENAME_SIZE_VERSION_400; -#else - of.lStructSize = sizeof(of); -#endif of.hwndOwner = hwnd; if (ppk) { of.lpstrFilter = "PuTTY Private Key Files (*.ppk)\0*.ppk\0" @@ -217,13 +210,9 @@ static int prompt_keyfile(HWND hwnd, char *dlgtitle, *filename = '\0'; of.nMaxFile = FILENAME_MAX; of.lpstrFileTitle = NULL; - of.lpstrInitialDir = NULL; of.lpstrTitle = dlgtitle; of.Flags = 0; - if (save) - return GetSaveFileName(&of); - else - return GetOpenFileName(&of); + return request_file(NULL, &of, FALSE, save); } /* @@ -632,6 +621,7 @@ void load_key_file(HWND hwnd, struct MainDlgState *state, int needs_pass; int type, realtype; int ret; + const char *errmsg = NULL; char *comment; struct PassphraseProcStruct pps; struct RSAKey newkey1; @@ -641,11 +631,11 @@ void load_key_file(HWND hwnd, struct MainDlgState *state, if (type != SSH_KEYTYPE_SSH1 && type != SSH_KEYTYPE_SSH2 && !import_possible(type)) { - char msg[256]; - sprintf(msg, "Couldn't load private key (%s)", - key_type_to_str(type)); + char *msg = dupprintf("Couldn't load private key (%s)", + key_type_to_str(type)); MessageBox(NULL, msg, "PuTTYgen Error", MB_OK | MB_ICONERROR); + sfree(msg); return; } @@ -682,17 +672,17 @@ void load_key_file(HWND hwnd, struct MainDlgState *state, if (type == SSH_KEYTYPE_SSH1) { if (realtype == type) ret = loadrsakey(&filename, &newkey1, - passphrase, NULL); + passphrase, &errmsg); else ret = import_ssh1(&filename, realtype, - &newkey1, passphrase); + &newkey1, passphrase, &errmsg); } else { if (realtype == type) newkey2 = ssh2_load_userkey(&filename, - passphrase, NULL); + passphrase, &errmsg); else newkey2 = import_ssh2(&filename, realtype, - passphrase); + passphrase, &errmsg); if (newkey2 == SSH2_WRONG_PASSPHRASE) ret = -1; else if (!newkey2) @@ -704,8 +694,9 @@ void load_key_file(HWND hwnd, struct MainDlgState *state, if (comment) sfree(comment); if (ret == 0) { - MessageBox(NULL, "Couldn't load private key.", - "PuTTYgen Error", MB_OK | MB_ICONERROR); + char *msg = dupprintf("Couldn't load private key (%s)", errmsg); + MessageBox(NULL, msg, "PuTTYgen Error", MB_OK | MB_ICONERROR); + sfree(msg); } else if (ret == 1) { /* * Now update the key controls with all the