diff options
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 @@ | |||
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 |