]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Fix error checking in uxstore.c: add a missing check, and fix a
authorSimon Tatham <anakin@pobox.com>
Sun, 21 Jul 2013 07:40:30 +0000 (07:40 +0000)
committerSimon Tatham <anakin@pobox.com>
Sun, 21 Jul 2013 07:40:30 +0000 (07:40 +0000)
mis-cut-and-pasted one.

[originally from svn r9950]

unix/uxstore.c

index 372c224d5d179091e62f2438f6d418d3921b7425..d97185e1efbcab674328d199efa549a2e6b4504d 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);