summaryrefslogtreecommitdiffstats
path: root/hostfile.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2020-06-26 05:42:16 +0000
committerDamien Miller <djm@mindrot.org>2020-06-26 15:44:47 +1000
commit976c4f86286d52a0cb2aadf4a095d379c0da752e (patch)
tree39f721d68c5e000b5943a3d864863cb4dd9b0752 /hostfile.c
parent32b2502a9dfdfded1ccdc1fd6dc2b3fe41bfc205 (diff)
upstream: avoid spurious error message when ssh-keygen creates files
outside ~/.ssh; with dtucker@ OpenBSD-Commit-ID: ac0c662d44607e00ec78c266ee60752beb1c7e08
Diffstat (limited to 'hostfile.c')
-rw-r--r--hostfile.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/hostfile.c b/hostfile.c
index 1cc4dba9..936d8c9b 100644
--- a/hostfile.c
+++ b/hostfile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hostfile.c,v 1.81 2020/06/26 05:02:03 dtucker Exp $ */
+/* $OpenBSD: hostfile.c,v 1.82 2020/06/26 05:42:16 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -465,9 +465,10 @@ hostfile_create_user_ssh_dir(const char *filename, int notify)
return;
len = p - filename;
dotsshdir = tilde_expand_filename("~/" _PATH_SSH_USER_DIR, getuid());
- if ((strlen(dotsshdir) > len || strncmp(filename, dotsshdir, len) != 0
- || stat(dotsshdir, &st)) == 0)
- ; /* do nothing, path not in ~/.ssh or dir already exists */
+ if (strlen(dotsshdir) > len || strncmp(filename, dotsshdir, len) != 0)
+ goto out; /* not ~/.ssh prefixed */
+ if (stat(dotsshdir, &st) == 0)
+ goto out; /* dir already exists */
else if (errno != ENOENT)
error("Could not stat %s: %s", dotsshdir, strerror(errno));
else {
@@ -483,6 +484,7 @@ hostfile_create_user_ssh_dir(const char *filename, int notify)
ssh_selinux_setfscreatecon(NULL);
#endif
}
+ out:
free(dotsshdir);
}