summaryrefslogtreecommitdiff
path: root/readconf.c
diff options
context:
space:
mode:
Diffstat (limited to 'readconf.c')
-rw-r--r--readconf.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/readconf.c b/readconf.c
index dc884c9b1..a4ecf7a0b 100644
--- a/readconf.c
+++ b/readconf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: readconf.c,v 1.218 2014/02/23 20:11:36 djm Exp $ */ 1/* $OpenBSD: readconf.c,v 1.219 2014/04/23 12:42:34 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
@@ -345,6 +345,7 @@ add_identity_file(Options *options, const char *dir, const char *filename,
345 int userprovided) 345 int userprovided)
346{ 346{
347 char *path; 347 char *path;
348 int i;
348 349
349 if (options->num_identity_files >= SSH_MAX_IDENTITY_FILES) 350 if (options->num_identity_files >= SSH_MAX_IDENTITY_FILES)
350 fatal("Too many identity files specified (max %d)", 351 fatal("Too many identity files specified (max %d)",
@@ -355,6 +356,16 @@ add_identity_file(Options *options, const char *dir, const char *filename,
355 else 356 else
356 (void)xasprintf(&path, "%.100s%.100s", dir, filename); 357 (void)xasprintf(&path, "%.100s%.100s", dir, filename);
357 358
359 /* Avoid registering duplicates */
360 for (i = 0; i < options->num_identity_files; i++) {
361 if (options->identity_file_userprovided[i] == userprovided &&
362 strcmp(options->identity_files[i], path) == 0) {
363 debug2("%s: ignoring duplicate key %s", __func__, path);
364 free(path);
365 return;
366 }
367 }
368
358 options->identity_file_userprovided[options->num_identity_files] = 369 options->identity_file_userprovided[options->num_identity_files] =
359 userprovided; 370 userprovided;
360 options->identity_files[options->num_identity_files++] = path; 371 options->identity_files[options->num_identity_files++] = path;