diff options
author | djm@openbsd.org <djm@openbsd.org> | 2017-03-10 05:26:06 +0100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2017-03-10 05:35:39 +0100 |
commit | db2597207e69912f2592cd86a1de8e948a9d7ffb (patch) | |
tree | a21ec4fe01db6c7ccfcfdc52cacb9761a4693a52 /hostfile.c | |
parent | upstream commit (diff) | |
download | openssh-db2597207e69912f2592cd86a1de8e948a9d7ffb.tar.xz openssh-db2597207e69912f2592cd86a1de8e948a9d7ffb.zip |
upstream commit
ensure hostname is lower-case before hashing it;
bz#2591 reported by Griff Miller II; ok dtucker@
Upstream-ID: c3b8b93804f376bd00d859b8bcd9fc0d86b4db17
Diffstat (limited to 'hostfile.c')
-rw-r--r-- | hostfile.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/hostfile.c b/hostfile.c index 4548fbab3..e23faa969 100644 --- a/hostfile.c +++ b/hostfile.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hostfile.c,v 1.67 2016/09/17 18:00:27 tedu Exp $ */ +/* $OpenBSD: hostfile.c,v 1.68 2017/03/10 04:26:06 djm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -419,19 +419,24 @@ write_host_entry(FILE *f, const char *host, const char *ip, const struct sshkey *key, int store_hash) { int r, success = 0; - char *hashed_host = NULL; + char *hashed_host = NULL, *lhost; + + lhost = xstrdup(host); + lowercase(lhost); if (store_hash) { - if ((hashed_host = host_hash(host, NULL, 0)) == NULL) { + if ((hashed_host = host_hash(lhost, NULL, 0)) == NULL) { error("%s: host_hash failed", __func__); + free(lhost); return 0; } fprintf(f, "%s ", hashed_host); } else if (ip != NULL) - fprintf(f, "%s,%s ", host, ip); - else - fprintf(f, "%s ", host); - + fprintf(f, "%s,%s ", lhost, ip); + else { + fprintf(f, "%s ", lhost); + } + free(lhost); if ((r = sshkey_write(key, f)) == 0) success = 1; else |