Fix error checking in uxstore.c: add a missing check, and fix a
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sun, 21 Jul 2013 07:40:30 +0000 (07:40 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sun, 21 Jul 2013 07:40:30 +0000 (07:40 +0000)
mis-cut-and-pasted one.

git-svn-id: svn://svn.tartarus.org/sgt/putty@9950 cda61777-01e9-0310-a592-d414129be87e

unix/uxstore.c

index 372c224..d97185e 100644 (file)
@@ -651,7 +651,12 @@ void store_host_key(const char *hostname, int port,
 
     fclose(wfp);
 
-    rename(tmpfilename, filename);
+    if (rename(tmpfilename, filename) < 0) {
+        char *msg = dupprintf("Unable to store host key: rename(\"%s\",\"%s\")"
+                              " returned '%s'", tmpfilename, filename,
+                              strerror(errno));
+        nonfatal(msg);
+    }
 
     sfree(tmpfilename);
     sfree(filename);
@@ -711,7 +716,7 @@ void write_random_seed(void *data, int len)
        sfree(dir);
 
        fd = open(fname, O_CREAT | O_WRONLY, 0600);
-        if (errno != ENOENT) {
+        if (fd < 0) {
             char *msg = dupprintf("Unable to write random seed: open(\"%s\") "
                                   "returned '%s'", fname, strerror(errno));
             nonfatal(msg);