From ba9cb5ecbb10de0566a9a4b1785f10bc42ec198f Mon Sep 17 00:00:00 2001 From: simon Date: Sun, 21 Jul 2013 07:40:30 +0000 Subject: [PATCH] Fix error checking in uxstore.c: add a missing check, and fix a mis-cut-and-pasted one. git-svn-id: svn://svn.tartarus.org/sgt/putty@9950 cda61777-01e9-0310-a592-d414129be87e --- unix/uxstore.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/unix/uxstore.c b/unix/uxstore.c index 372c224d..d97185e1 100644 --- a/unix/uxstore.c +++ b/unix/uxstore.c @@ -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); -- 2.11.0