diff options
author | djm@openbsd.org <djm@openbsd.org> | 2018-07-16 07:06:50 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2018-07-16 17:08:13 +1000 |
commit | 3eb7f1038d17af7aea3c2c62d1e30cd545607640 (patch) | |
tree | db610540aeb0bbbe3c9f04c20640f67a2b20837c /ssh.c | |
parent | 2f131e1b34502aa19f345e89cabf6fa3fc097f09 (diff) |
upstream: keep options.identity_file_userprovided array in sync when we
load keys, fixing some spurious error messages; ok markus
OpenBSD-Commit-ID: c63e3d5200ee2cf9e35bda98de847302566c6a00
Diffstat (limited to 'ssh.c')
-rw-r--r-- | ssh.c | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh.c,v 1.483 2018/07/11 18:53:29 markus Exp $ */ | 1 | /* $OpenBSD: ssh.c,v 1.484 2018/07/16 07:06:50 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 |
@@ -2037,8 +2037,10 @@ load_public_identity_files(struct passwd *pw) | |||
2037 | u_int n_ids, n_certs; | 2037 | u_int n_ids, n_certs; |
2038 | char *identity_files[SSH_MAX_IDENTITY_FILES]; | 2038 | char *identity_files[SSH_MAX_IDENTITY_FILES]; |
2039 | struct sshkey *identity_keys[SSH_MAX_IDENTITY_FILES]; | 2039 | struct sshkey *identity_keys[SSH_MAX_IDENTITY_FILES]; |
2040 | int identity_file_userprovided[SSH_MAX_IDENTITY_FILES]; | ||
2040 | char *certificate_files[SSH_MAX_CERTIFICATE_FILES]; | 2041 | char *certificate_files[SSH_MAX_CERTIFICATE_FILES]; |
2041 | struct sshkey *certificates[SSH_MAX_CERTIFICATE_FILES]; | 2042 | struct sshkey *certificates[SSH_MAX_CERTIFICATE_FILES]; |
2043 | int certificate_file_userprovided[SSH_MAX_CERTIFICATE_FILES]; | ||
2042 | #ifdef ENABLE_PKCS11 | 2044 | #ifdef ENABLE_PKCS11 |
2043 | struct sshkey **keys; | 2045 | struct sshkey **keys; |
2044 | int nkeys; | 2046 | int nkeys; |
@@ -2047,8 +2049,12 @@ load_public_identity_files(struct passwd *pw) | |||
2047 | n_ids = n_certs = 0; | 2049 | n_ids = n_certs = 0; |
2048 | memset(identity_files, 0, sizeof(identity_files)); | 2050 | memset(identity_files, 0, sizeof(identity_files)); |
2049 | memset(identity_keys, 0, sizeof(identity_keys)); | 2051 | memset(identity_keys, 0, sizeof(identity_keys)); |
2052 | memset(identity_file_userprovided, 0, | ||
2053 | sizeof(identity_file_userprovided)); | ||
2050 | memset(certificate_files, 0, sizeof(certificate_files)); | 2054 | memset(certificate_files, 0, sizeof(certificate_files)); |
2051 | memset(certificates, 0, sizeof(certificates)); | 2055 | memset(certificates, 0, sizeof(certificates)); |
2056 | memset(certificate_file_userprovided, 0, | ||
2057 | sizeof(certificate_file_userprovided)); | ||
2052 | 2058 | ||
2053 | #ifdef ENABLE_PKCS11 | 2059 | #ifdef ENABLE_PKCS11 |
2054 | if (options.pkcs11_provider != NULL && | 2060 | if (options.pkcs11_provider != NULL && |
@@ -2091,7 +2097,8 @@ load_public_identity_files(struct passwd *pw) | |||
2091 | free(options.identity_files[i]); | 2097 | free(options.identity_files[i]); |
2092 | identity_files[n_ids] = filename; | 2098 | identity_files[n_ids] = filename; |
2093 | identity_keys[n_ids] = public; | 2099 | identity_keys[n_ids] = public; |
2094 | 2100 | identity_file_userprovided[n_ids] = | |
2101 | options.identity_file_userprovided[i]; | ||
2095 | if (++n_ids >= SSH_MAX_IDENTITY_FILES) | 2102 | if (++n_ids >= SSH_MAX_IDENTITY_FILES) |
2096 | continue; | 2103 | continue; |
2097 | 2104 | ||
@@ -2120,6 +2127,8 @@ load_public_identity_files(struct passwd *pw) | |||
2120 | /* NB. leave filename pointing to private key */ | 2127 | /* NB. leave filename pointing to private key */ |
2121 | identity_files[n_ids] = xstrdup(filename); | 2128 | identity_files[n_ids] = xstrdup(filename); |
2122 | identity_keys[n_ids] = public; | 2129 | identity_keys[n_ids] = public; |
2130 | identity_file_userprovided[n_ids] = | ||
2131 | options.identity_file_userprovided[i]; | ||
2123 | n_ids++; | 2132 | n_ids++; |
2124 | } | 2133 | } |
2125 | 2134 | ||
@@ -2157,17 +2166,24 @@ load_public_identity_files(struct passwd *pw) | |||
2157 | } | 2166 | } |
2158 | certificate_files[n_certs] = filename; | 2167 | certificate_files[n_certs] = filename; |
2159 | certificates[n_certs] = public; | 2168 | certificates[n_certs] = public; |
2169 | certificate_file_userprovided[n_certs] = | ||
2170 | options.certificate_file_userprovided[i]; | ||
2160 | ++n_certs; | 2171 | ++n_certs; |
2161 | } | 2172 | } |
2162 | 2173 | ||
2163 | options.num_identity_files = n_ids; | 2174 | options.num_identity_files = n_ids; |
2164 | memcpy(options.identity_files, identity_files, sizeof(identity_files)); | 2175 | memcpy(options.identity_files, identity_files, sizeof(identity_files)); |
2165 | memcpy(options.identity_keys, identity_keys, sizeof(identity_keys)); | 2176 | memcpy(options.identity_keys, identity_keys, sizeof(identity_keys)); |
2177 | memcpy(options.identity_file_userprovided, | ||
2178 | identity_file_userprovided, sizeof(identity_file_userprovided)); | ||
2166 | 2179 | ||
2167 | options.num_certificate_files = n_certs; | 2180 | options.num_certificate_files = n_certs; |
2168 | memcpy(options.certificate_files, | 2181 | memcpy(options.certificate_files, |
2169 | certificate_files, sizeof(certificate_files)); | 2182 | certificate_files, sizeof(certificate_files)); |
2170 | memcpy(options.certificates, certificates, sizeof(certificates)); | 2183 | memcpy(options.certificates, certificates, sizeof(certificates)); |
2184 | memcpy(options.certificate_file_userprovided, | ||
2185 | certificate_file_userprovided, | ||
2186 | sizeof(certificate_file_userprovided)); | ||
2171 | } | 2187 | } |
2172 | 2188 | ||
2173 | static void | 2189 | static void |