X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/1a41869194d74448de0b003f6f9f61468e44231b..47489d8daef971352cfb1ec30c998ed7b048c97c:/puttygen.c diff --git a/puttygen.c b/puttygen.c index 072b7d05..7bfd1e6d 100644 --- a/puttygen.c +++ b/puttygen.c @@ -22,6 +22,23 @@ static int requested_help; static char *cmdline_keyfile = NULL; +/* + * Print a modal (Really Bad) message box and perform a fatal exit. + */ +void modalfatalbox(char *fmt, ...) +{ + va_list ap; + char *stuff; + + va_start(ap, fmt); + stuff = dupvprintf(fmt, ap); + va_end(ap); + MessageBox(NULL, stuff, "PuTTYgen Fatal Error", + MB_SYSTEMMODAL | MB_ICONERROR | MB_OK); + sfree(stuff); + exit(1); +} + /* ---------------------------------------------------------------------- * Progress report code. This is really horrible :-) */ @@ -185,7 +202,8 @@ static int prompt_keyfile(HWND hwnd, char *dlgtitle, #endif of.hwndOwner = hwnd; if (ppk) { - of.lpstrFilter = "PuTTY Private Key Files\0*.PPK\0All Files\0*\0\0\0"; + of.lpstrFilter = "PuTTY Private Key Files (*.ppk)\0*.PPK\0" + "All Files\0*\0\0\0"; of.lpstrDefExt = ".ppk"; } else { of.lpstrFilter = "All Files\0*\0\0\0"; @@ -206,14 +224,6 @@ static int prompt_keyfile(HWND hwnd, char *dlgtitle, } /* - * This function is needed to link with the DES code. We need not - * have it do anything at all. - */ -void logevent(char *msg) -{ -} - -/* * Dialog-box function for the Licence box. */ static int CALLBACK LicenceProc(HWND hwnd, UINT msg, @@ -356,10 +366,8 @@ static void setupbigedit1(HWND hwnd, int id, int idstatic, struct RSAKey *key) dec1 = bignum_decimal(key->exponent); dec2 = bignum_decimal(key->modulus); - buffer = smalloc(strlen(dec1) + strlen(dec2) + - strlen(key->comment) + 30); - sprintf(buffer, "%d %s %s %s", - bignum_bitcount(key->modulus), dec1, dec2, key->comment); + buffer = dupprintf("%d %s %s %s", bignum_bitcount(key->modulus), + dec1, dec2, key->comment); SetDlgItemText(hwnd, id, buffer); SetDlgItemText(hwnd, idstatic, "&Public key for pasting into authorized_keys file:"); @@ -1146,12 +1154,13 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, int ret; FILE *fp = fopen(filename, "r"); if (fp) { - char buffer[FILENAME_MAX + 80]; + char *buffer; fclose(fp); - sprintf(buffer, "Overwrite existing file\n%.*s?", - FILENAME_MAX, filename); + buffer = dupprintf("Overwrite existing file\n%s?", + filename); ret = MessageBox(hwnd, buffer, "PuTTYgen Warning", MB_YESNO | MB_ICONWARNING); + sfree(buffer); if (ret != IDYES) break; } @@ -1189,12 +1198,13 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, int ret; FILE *fp = fopen(filename, "r"); if (fp) { - char buffer[FILENAME_MAX + 80]; + char *buffer; fclose(fp); - sprintf(buffer, "Overwrite existing file\n%.*s?", - FILENAME_MAX, filename); + buffer = dupprintf("Overwrite existing file\n%s?", + filename); ret = MessageBox(hwnd, buffer, "PuTTYgen Warning", MB_YESNO | MB_ICONWARNING); + sfree(buffer); if (ret != IDYES) break; } @@ -1384,7 +1394,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) int argc; char **argv; - split_into_argv(cmdline, &argc, &argv); + split_into_argv(cmdline, &argc, &argv, NULL); if (argc > 0) { /*