X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/65a22376e5875181e41108028091018cdcd4fdae..37d868ecb7ff6ba8aad4b8325c016c0a045f6bb3:/puttygen.c?ds=sidebyside diff --git a/puttygen.c b/puttygen.c index e93781c4..6f5d8164 100644 --- a/puttygen.c +++ b/puttygen.c @@ -93,7 +93,7 @@ struct PassphraseProcStruct { */ static int CALLBACK PassphraseProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - static char *passphrase; + static char *passphrase = NULL; struct PassphraseProcStruct *p; switch (msg) { @@ -121,6 +121,7 @@ static int CALLBACK PassphraseProc(HWND hwnd, UINT msg, if (p->comment) SetDlgItemText(hwnd, 101, p->comment); *passphrase = 0; + SetDlgItemText(hwnd, 102, passphrase); return 0; case WM_COMMAND: switch (LOWORD(wParam)) { @@ -134,7 +135,7 @@ static int CALLBACK PassphraseProc(HWND hwnd, UINT msg, EndDialog (hwnd, 0); return 0; case 102: /* edit box */ - if (HIWORD(wParam) == EN_CHANGE) { + if ((HIWORD(wParam) == EN_CHANGE) && passphrase) { GetDlgItemText (hwnd, 102, passphrase, PASSPHRASE_MAXLEN-1); passphrase[PASSPHRASE_MAXLEN-1] = '\0'; } @@ -314,7 +315,7 @@ static void setupbigedit1(HWND hwnd, int id, struct RSAKey *key) { buffer = smalloc(strlen(dec1)+strlen(dec2)+ strlen(key->comment)+30); sprintf(buffer, "%d %s %s %s", - ssh1_bignum_bitcount(key->modulus), + bignum_bitcount(key->modulus), dec1, dec2, key->comment); SetDlgItemText(hwnd, id, buffer); sfree(dec1); @@ -325,7 +326,7 @@ static void setupbigedit1(HWND hwnd, int id, struct RSAKey *key) { static void setupbigedit2(HWND hwnd, int id, struct ssh2_userkey *key) { unsigned char *pub_blob; char *buffer, *p; - int pub_len, buflen; + int pub_len; int i; pub_blob = key->alg->public_blob(key->data, &pub_len); @@ -530,8 +531,13 @@ static int CALLBACK MainDlgProc (HWND hwnd, UINT msg, sfree(*state->commentptr); *state->commentptr = smalloc(len+1); GetWindowText(editctl, *state->commentptr, len+1); - } - } + if (state->ssh2) { + setupbigedit2(hwnd, IDC_KEYDISPLAY, &state->ssh2key); + } else { + setupbigedit1(hwnd, IDC_KEYDISPLAY, &state->key); + } + } + } break; case IDC_ABOUT: EnableWindow(hwnd, 0); @@ -789,10 +795,13 @@ static int CALLBACK MainDlgProc (HWND hwnd, UINT msg, EnableWindow(GetDlgItem(hwnd, IDC_GENERATE), 1); EnableWindow(GetDlgItem(hwnd, IDC_LOAD), 1); EnableWindow(GetDlgItem(hwnd, IDC_SAVE), 1); - if (state->ssh2) + if (state->ssh2) { + state->ssh2key.data = &state->key; + state->ssh2key.alg = &ssh_rsa; state->commentptr = &state->ssh2key.comment; - else + } else { state->commentptr = &state->key.comment; + } /* * Invent a comment for the key. We'll do this by including * the date in it. This will be so horrifyingly ugly that