diff options
author | naddy@openbsd.org <naddy@openbsd.org> | 2017-05-05 10:42:49 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2017-05-08 09:18:27 +1000 |
commit | 3e371bd2124427403971db853fb2e36ce789b6fd (patch) | |
tree | d05946a4ef052a51cb1c5f867669961e661bbdb0 /authfd.c | |
parent | 2e9c324b3a7f15c092d118c2ac9490939f6228fd (diff) |
upstream commit
more simplification and removal of SSHv1-related code;
ok djm@
Upstream-ID: d2f041aa0b79c0ebd98c68a01e5a0bfab2cf3b55
Diffstat (limited to 'authfd.c')
-rw-r--r-- | authfd.c | 46 |
1 files changed, 13 insertions, 33 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: authfd.c,v 1.102 2017/05/04 06:10:57 djm Exp $ */ | 1 | /* $OpenBSD: authfd.c,v 1.103 2017/05/05 10:42:49 naddy 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 |
@@ -227,35 +227,21 @@ deserialise_identity2(struct sshbuf *ids, struct sshkey **keyp, char **commentp) | |||
227 | * Fetch list of identities held by the agent. | 227 | * Fetch list of identities held by the agent. |
228 | */ | 228 | */ |
229 | int | 229 | int |
230 | ssh_fetch_identitylist(int sock, int version, struct ssh_identitylist **idlp) | 230 | ssh_fetch_identitylist(int sock, struct ssh_identitylist **idlp) |
231 | { | 231 | { |
232 | u_char type, code1 = 0, code2 = 0; | 232 | u_char type; |
233 | u_int32_t num, i; | 233 | u_int32_t num, i; |
234 | struct sshbuf *msg; | 234 | struct sshbuf *msg; |
235 | struct ssh_identitylist *idl = NULL; | 235 | struct ssh_identitylist *idl = NULL; |
236 | int r; | 236 | int r; |
237 | 237 | ||
238 | /* Determine request and expected response types */ | ||
239 | switch (version) { | ||
240 | case 1: | ||
241 | code1 = SSH_AGENTC_REQUEST_RSA_IDENTITIES; | ||
242 | code2 = SSH_AGENT_RSA_IDENTITIES_ANSWER; | ||
243 | break; | ||
244 | case 2: | ||
245 | code1 = SSH2_AGENTC_REQUEST_IDENTITIES; | ||
246 | code2 = SSH2_AGENT_IDENTITIES_ANSWER; | ||
247 | break; | ||
248 | default: | ||
249 | return SSH_ERR_INVALID_ARGUMENT; | ||
250 | } | ||
251 | |||
252 | /* | 238 | /* |
253 | * Send a message to the agent requesting for a list of the | 239 | * Send a message to the agent requesting for a list of the |
254 | * identities it can represent. | 240 | * identities it can represent. |
255 | */ | 241 | */ |
256 | if ((msg = sshbuf_new()) == NULL) | 242 | if ((msg = sshbuf_new()) == NULL) |
257 | return SSH_ERR_ALLOC_FAIL; | 243 | return SSH_ERR_ALLOC_FAIL; |
258 | if ((r = sshbuf_put_u8(msg, code1)) != 0) | 244 | if ((r = sshbuf_put_u8(msg, SSH2_AGENTC_REQUEST_IDENTITIES)) != 0) |
259 | goto out; | 245 | goto out; |
260 | 246 | ||
261 | if ((r = ssh_request_reply(sock, msg, msg)) != 0) | 247 | if ((r = ssh_request_reply(sock, msg, msg)) != 0) |
@@ -267,7 +253,7 @@ ssh_fetch_identitylist(int sock, int version, struct ssh_identitylist **idlp) | |||
267 | if (agent_failed(type)) { | 253 | if (agent_failed(type)) { |
268 | r = SSH_ERR_AGENT_FAILURE; | 254 | r = SSH_ERR_AGENT_FAILURE; |
269 | goto out; | 255 | goto out; |
270 | } else if (type != code2) { | 256 | } else if (type != SSH2_AGENT_IDENTITIES_ANSWER) { |
271 | r = SSH_ERR_INVALID_FORMAT; | 257 | r = SSH_ERR_INVALID_FORMAT; |
272 | goto out; | 258 | goto out; |
273 | } | 259 | } |
@@ -292,20 +278,14 @@ ssh_fetch_identitylist(int sock, int version, struct ssh_identitylist **idlp) | |||
292 | goto out; | 278 | goto out; |
293 | } | 279 | } |
294 | for (i = 0; i < num;) { | 280 | for (i = 0; i < num;) { |
295 | switch (version) { | 281 | if ((r = deserialise_identity2(msg, &(idl->keys[i]), |
296 | case 1: | 282 | &(idl->comments[i]))) != 0) { |
297 | break; | 283 | if (r == SSH_ERR_KEY_TYPE_UNKNOWN) { |
298 | case 2: | 284 | /* Gracefully skip unknown key types */ |
299 | if ((r = deserialise_identity2(msg, | 285 | num--; |
300 | &(idl->keys[i]), &(idl->comments[i]))) != 0) { | 286 | continue; |
301 | if (r == SSH_ERR_KEY_TYPE_UNKNOWN) { | 287 | } else |
302 | /* Gracefully skip unknown key types */ | 288 | goto out; |
303 | num--; | ||
304 | continue; | ||
305 | } else | ||
306 | goto out; | ||
307 | } | ||
308 | break; | ||
309 | } | 289 | } |
310 | i++; | 290 | i++; |
311 | } | 291 | } |