From fc9b052a2fc832ea8bc3efa9c79eba0f961830b2 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 22 Jul 2013 07:11:44 +0000 Subject: [PATCH] Report an error if deleting a random seed file fails. (This has also required me to add a currently unused nonfatal() to PuTTYgen, since although PuTTYgen won't actually try to delete putty.rnd, it does link in winstore.c as a whole.) git-svn-id: svn://svn.tartarus.org/sgt/putty@9957 cda61777-01e9-0310-a592-d414129be87e --- windows/winpgen.c | 16 ++++++++++++++++ windows/winstore.c | 5 ++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/windows/winpgen.c b/windows/winpgen.c index ffbeb1a4..aeebb629 100644 --- a/windows/winpgen.c +++ b/windows/winpgen.c @@ -41,6 +41,22 @@ void modalfatalbox(char *fmt, ...) exit(1); } +/* + * Print a non-fatal message box and do not exit. + */ +void nonfatal(char *fmt, ...) +{ + va_list ap; + char *stuff; + + va_start(ap, fmt); + stuff = dupvprintf(fmt, ap); + va_end(ap); + MessageBox(NULL, stuff, "PuTTYgen Error", + MB_SYSTEMMODAL | MB_ICONERROR | MB_OK); + sfree(stuff); +} + /* ---------------------------------------------------------------------- * Progress report code. This is really horrible :-) */ diff --git a/windows/winstore.c b/windows/winstore.c index 76c73d09..66c7c759 100644 --- a/windows/winstore.c +++ b/windows/winstore.c @@ -456,7 +456,10 @@ enum { DEL, OPEN_R, OPEN_W }; static int try_random_seed(char const *path, int action, HANDLE *ret) { if (action == DEL) { - remove(path); + if (!DeleteFile(path) && GetLastError() != ERROR_FILE_NOT_FOUND) { + nonfatal("Unable to delete '%s': %s", path, + win_strerror(GetLastError())); + } *ret = INVALID_HANDLE_VALUE; return FALSE; /* so we'll do the next ones too */ } -- 2.11.0