diff options
author | 2014-04-23 12:42:34 +0000 | |
---|---|---|
committer | 2014-04-23 12:42:34 +0000 | |
commit | 7f7be6c3c86cfe71d18ff7a7d58bd8a8b665b3e8 (patch) | |
tree | 356e4a7102535712afbb49baf77a2608cad3a5d8 | |
parent | Casting from a const unsigned char ** to a const unsigned char ** seems... (diff) | |
download | wireguard-openbsd-7f7be6c3c86cfe71d18ff7a7d58bd8a8b665b3e8.tar.xz wireguard-openbsd-7f7be6c3c86cfe71d18ff7a7d58bd8a8b665b3e8.zip |
don't record duplicate IdentityFiles
-rw-r--r-- | usr.bin/ssh/readconf.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/usr.bin/ssh/readconf.c b/usr.bin/ssh/readconf.c index 35dbd59dd66..453a21cfcc1 100644 --- a/usr.bin/ssh/readconf.c +++ b/usr.bin/ssh/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 @@ -336,6 +336,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)", @@ -346,6 +347,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; |