]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Report an error if deleting a random seed file fails.
authorSimon Tatham <anakin@pobox.com>
Mon, 22 Jul 2013 07:11:44 +0000 (07:11 +0000)
committerSimon Tatham <anakin@pobox.com>
Mon, 22 Jul 2013 07:11:44 +0000 (07:11 +0000)
(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.)

[originally from svn r9957]

windows/winpgen.c
windows/winstore.c

index ffbeb1a4ee0784cea95e4050b90c4428ce63adcf..aeebb629a4643f7df042285828fb0521b821df8a 100644 (file)
@@ -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 :-)
  */
index 76c73d096d5d89b946e0d3a67e8c75a2b8ffc6be..66c7c759488681bc5fcd66d3ea42329c9a597b3a 100644 (file)
@@ -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 */
     }