X-Git-Url: http://andersk.mit.edu/gitweb/openssh.git/blobdiff_plain/c5d10563138ba0f06f531c176e59ba06401386f5..e3fe98a266f4633540d19ffd58f3c2b0b31f285b:/ssh-rand-helper.c diff --git a/ssh-rand-helper.c b/ssh-rand-helper.c index 662f7008..8b1c4b4f 100644 --- a/ssh-rand-helper.c +++ b/ssh-rand-helper.c @@ -28,12 +28,25 @@ #include #include #include +#include + +#include +#include +#include + +#include +#include #ifdef HAVE_SYS_UN_H # include #endif +#include +#include +#include #include +#include +#include #include #include @@ -573,7 +586,8 @@ prng_write_seedfile(void) /* Try to ensure that the parent directory is there */ snprintf(filename, sizeof(filename), "%.512s/%s", pw->pw_dir, _PATH_SSH_USER_DIR); - mkdir(filename, 0700); + if (mkdir(filename, 0700) < 0 && errno != EEXIST) + fatal("mkdir %.200s: %s", filename, strerror(errno)); snprintf(filename, sizeof(filename), "%.512s/%s", pw->pw_dir, SSH_PRNG_SEED_FILE); @@ -674,8 +688,7 @@ prng_read_commands(char *cmdfilename) } num_cmds = 64; - entcmd = xmalloc(num_cmds * sizeof(entropy_cmd_t)); - memset(entcmd, '\0', num_cmds * sizeof(entropy_cmd_t)); + entcmd = xcalloc(num_cmds, sizeof(entropy_cmd_t)); /* Read in file */ cur_cmd = linenum = 0; @@ -783,6 +796,7 @@ prng_read_commands(char *cmdfilename) debug("Loaded %d entropy commands from %.100s", cur_cmd, cmdfilename); + fclose(f); return cur_cmd < MIN_ENTROPY_SOURCES ? -1 : 0; }