Skip to content

Commit c23122c

Browse files
committed
upstream: avoid leak of fingerprint on error path; from Lidong Yan via
GHPR611 OpenBSD-Commit-ID: 253f6f7d729d8636da23ac9925b60b494e85a810
1 parent 6157e1c commit c23122c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

hostfile.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: hostfile.c,v 1.99 2025/05/06 05:40:56 djm Exp $ */
1+
/* $OpenBSD: hostfile.c,v 1.100 2025/11/25 00:57:04 djm Exp $ */
22
/*
33
* Author: Tatu Ylonen <ylo@cs.hut.fi>
44
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -626,7 +626,7 @@ hostfile_replace_entries(const char *filename, const char *host, const char *ip,
626626
int r, fd, oerrno = 0;
627627
int loglevel = quiet ? SYSLOG_LEVEL_DEBUG1 : SYSLOG_LEVEL_VERBOSE;
628628
struct host_delete_ctx ctx;
629-
char *fp, *temp = NULL, *back = NULL;
629+
char *fp = NULL, *temp = NULL, *back = NULL;
630630
const char *what;
631631
mode_t omask;
632632
size_t i;
@@ -715,6 +715,7 @@ hostfile_replace_entries(const char *filename, const char *host, const char *ip,
715715
host, ip == NULL ? "" : ",", ip == NULL ? "" : ip, filename,
716716
sshkey_ssh_name(keys[i]), fp);
717717
free(fp);
718+
fp = NULL;
718719
ctx.modified = 1;
719720
}
720721
fclose(ctx.out);
@@ -755,6 +756,7 @@ hostfile_replace_entries(const char *filename, const char *host, const char *ip,
755756
unlink(temp);
756757
free(temp);
757758
free(back);
759+
free(fp);
758760
if (ctx.out != NULL)
759761
fclose(ctx.out);
760762
free(ctx.match_keys);

0 commit comments

Comments
 (0)