Kylene Jo Hall
2006-May-15 20:19 UTC
[PATCH 12/12] bug fix: openssh 4.3p2 ssh-rand-helper bugs
There are 2 bugs here. Since mkdir can return an error. The rest of the function's operations depend on this directory being created thus an error should be handled at this point. The second is f is never closed. This patch adds the needed fclose. This entire set of patches passed the regression tests on my system. Bugs found by Coverity. Signed-off-by: Kylene Hall <kjhall at us.ibm.com> --- ssh-rand-helper.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletion(-) diff -uprN openssh-4.3p2/ssh-rand-helper.c openssh-4.3p2-kylie/ssh-rand-helper.c --- openssh-4.3p2/ssh-rand-helper.c 2005-07-17 02:26:44.000000000 -0500 +++ openssh-4.3p2-kylie/ssh-rand-helper.c 2006-05-08 15:22:13.967153672 -0500 @@ -564,7 +564,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) + fatal("mkdir: %s", strerror(errno)); snprintf(filename, sizeof(filename), "%.512s/%s", pw->pw_dir, SSH_PRNG_SEED_FILE); @@ -774,6 +775,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; }