diff options
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | readconf.c | 13 |
2 files changed, 15 insertions, 1 deletions
@@ -22,6 +22,9 @@ | |||
22 | - jmc@cvs.openbsd.org 2014/04/22 14:16:30 | 22 | - jmc@cvs.openbsd.org 2014/04/22 14:16:30 |
23 | [sftp.1] | 23 | [sftp.1] |
24 | zap eol whitespace; | 24 | zap eol whitespace; |
25 | - djm@cvs.openbsd.org 2014/04/23 12:42:34 | ||
26 | [readconf.c] | ||
27 | don't record duplicate IdentityFiles | ||
25 | 28 | ||
26 | 20140430 | 29 | 20140430 |
27 | - (dtucker) [defines.h] Define __GNUC_PREREQ__ macro if we don't already | 30 | - (dtucker) [defines.h] Define __GNUC_PREREQ__ macro if we don't already |
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; |