summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordjm <djm>2014-05-15 03:47:56 +0000
committerdjm <djm>2014-05-15 03:47:56 +0000
commit660960711812009729ffb388d2ad26cc9b2d5279 (patch)
tree5af61b0f126af3a70740e575b302942e46dea9a7
parent6b0f2e102eff2ca1de7479c10f59d25f7c9b9484 (diff)
downloadopenssh-660960711812009729ffb388d2ad26cc9b2d5279.tar.gz
- djm@cvs.openbsd.org 2014/04/23 12:42:34
[readconf.c] don't record duplicate IdentityFiles
-rw-r--r--ChangeLog3
-rw-r--r--readconf.c13
2 files changed, 15 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 66e03a38..ba6e0607 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -22,6 +22,9 @@
- jmc@cvs.openbsd.org 2014/04/22 14:16:30
[sftp.1]
zap eol whitespace;
+ - djm@cvs.openbsd.org 2014/04/23 12:42:34
+ [readconf.c]
+ don't record duplicate IdentityFiles
20140430
- (dtucker) [defines.h] Define __GNUC_PREREQ__ macro if we don't already
diff --git a/readconf.c b/readconf.c
index dc884c9b..a4ecf7a0 100644
--- a/readconf.c
+++ b/readconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: readconf.c,v 1.218 2014/02/23 20:11:36 djm Exp $ */
+/* $OpenBSD: readconf.c,v 1.219 2014/04/23 12:42:34 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -345,6 +345,7 @@ add_identity_file(Options *options, const char *dir, const char *filename,
int userprovided)
{
char *path;
+ int i;
if (options->num_identity_files >= SSH_MAX_IDENTITY_FILES)
fatal("Too many identity files specified (max %d)",
@@ -355,6 +356,16 @@ add_identity_file(Options *options, const char *dir, const char *filename,
else
(void)xasprintf(&path, "%.100s%.100s", dir, filename);
+ /* Avoid registering duplicates */
+ for (i = 0; i < options->num_identity_files; i++) {
+ if (options->identity_file_userprovided[i] == userprovided &&
+ strcmp(options->identity_files[i], path) == 0) {
+ debug2("%s: ignoring duplicate key %s", __func__, path);
+ free(path);
+ return;
+ }
+ }
+
options->identity_file_userprovided[options->num_identity_files] =
userprovided;
options->identity_files[options->num_identity_files++] = path;