diff options
-rw-r--r-- | hostfile.c | 19 | ||||
-rw-r--r-- | ssh-keygen.c | 3 | ||||
-rw-r--r-- | ssh-keyscan.c | 3 |
3 files changed, 16 insertions, 9 deletions
diff --git a/hostfile.c b/hostfile.c index 4548fbab3..e23faa969 100644 --- a/hostfile.c +++ b/hostfile.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: hostfile.c,v 1.67 2016/09/17 18:00:27 tedu Exp $ */ | 1 | /* $OpenBSD: hostfile.c,v 1.68 2017/03/10 04:26:06 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * 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, | |||
419 | const struct sshkey *key, int store_hash) | 419 | const struct sshkey *key, int store_hash) |
420 | { | 420 | { |
421 | int r, success = 0; | 421 | int r, success = 0; |
422 | char *hashed_host = NULL; | 422 | char *hashed_host = NULL, *lhost; |
423 | |||
424 | lhost = xstrdup(host); | ||
425 | lowercase(lhost); | ||
423 | 426 | ||
424 | if (store_hash) { | 427 | if (store_hash) { |
425 | if ((hashed_host = host_hash(host, NULL, 0)) == NULL) { | 428 | if ((hashed_host = host_hash(lhost, NULL, 0)) == NULL) { |
426 | error("%s: host_hash failed", __func__); | 429 | error("%s: host_hash failed", __func__); |
430 | free(lhost); | ||
427 | return 0; | 431 | return 0; |
428 | } | 432 | } |
429 | fprintf(f, "%s ", hashed_host); | 433 | fprintf(f, "%s ", hashed_host); |
430 | } else if (ip != NULL) | 434 | } else if (ip != NULL) |
431 | fprintf(f, "%s,%s ", host, ip); | 435 | fprintf(f, "%s,%s ", lhost, ip); |
432 | else | 436 | else { |
433 | fprintf(f, "%s ", host); | 437 | fprintf(f, "%s ", lhost); |
434 | 438 | } | |
439 | free(lhost); | ||
435 | if ((r = sshkey_write(key, f)) == 0) | 440 | if ((r = sshkey_write(key, f)) == 0) |
436 | success = 1; | 441 | success = 1; |
437 | else | 442 | else |
diff --git a/ssh-keygen.c b/ssh-keygen.c index 6fd1f0348..f17af036b 100644 --- a/ssh-keygen.c +++ b/ssh-keygen.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh-keygen.c,v 1.298 2017/03/06 02:03:20 dtucker Exp $ */ | 1 | /* $OpenBSD: ssh-keygen.c,v 1.299 2017/03/10 04:26:06 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -1108,6 +1108,7 @@ known_hosts_hash(struct hostkey_foreach_line *l, void *_ctx) | |||
1108 | */ | 1108 | */ |
1109 | ohosts = hosts = xstrdup(l->hosts); | 1109 | ohosts = hosts = xstrdup(l->hosts); |
1110 | while ((cp = strsep(&hosts, ",")) != NULL && *cp != '\0') { | 1110 | while ((cp = strsep(&hosts, ",")) != NULL && *cp != '\0') { |
1111 | lowercase(cp); | ||
1111 | if ((hashed = host_hash(cp, NULL, 0)) == NULL) | 1112 | if ((hashed = host_hash(cp, NULL, 0)) == NULL) |
1112 | fatal("hash_host failed"); | 1113 | fatal("hash_host failed"); |
1113 | fprintf(ctx->out, "%s %s\n", hashed, l->rawkey); | 1114 | fprintf(ctx->out, "%s %s\n", hashed, l->rawkey); |
diff --git a/ssh-keyscan.c b/ssh-keyscan.c index e34286e47..1f95239a3 100644 --- a/ssh-keyscan.c +++ b/ssh-keyscan.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh-keyscan.c,v 1.108 2017/03/10 03:18:24 djm Exp $ */ | 1 | /* $OpenBSD: ssh-keyscan.c,v 1.109 2017/03/10 04:26:06 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>. | 3 | * Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>. |
4 | * | 4 | * |
@@ -327,6 +327,7 @@ keyprint_one(const char *host, struct sshkey *key) | |||
327 | const char *known_host, *hashed; | 327 | const char *known_host, *hashed; |
328 | 328 | ||
329 | hostport = put_host_port(host, ssh_port); | 329 | hostport = put_host_port(host, ssh_port); |
330 | lowercase(hostport); | ||
330 | if (hash_hosts && (hashed = host_hash(host, NULL, 0)) == NULL) | 331 | if (hash_hosts && (hashed = host_hash(host, NULL, 0)) == NULL) |
331 | fatal("host_hash failed"); | 332 | fatal("host_hash failed"); |
332 | known_host = hash_hosts ? hashed : hostport; | 333 | known_host = hash_hosts ? hashed : hostport; |