=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/ssh-agent.c,v retrieving revision 1.268 retrieving revision 1.269 diff -u -r1.268 -r1.269 --- src/usr.bin/ssh/ssh-agent.c 2021/01/11 02:12:58 1.268 +++ src/usr.bin/ssh/ssh-agent.c 2021/01/26 00:47:47 1.269 @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-agent.c,v 1.268 2021/01/11 02:12:58 dtucker Exp $ */ +/* $OpenBSD: ssh-agent.c,v 1.269 2021/01/26 00:47:47 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -161,11 +161,12 @@ close_socket(SocketEntry *e) { close(e->fd); - e->fd = -1; - e->type = AUTH_UNUSED; sshbuf_free(e->input); sshbuf_free(e->output); sshbuf_free(e->request); + memset(e, '\0', sizeof(*e)); + e->fd = -1; + e->type = AUTH_UNUSED; } static void @@ -235,6 +236,8 @@ struct sshbuf *msg; int r; + debug2_f("entering"); + if ((msg = sshbuf_new()) == NULL) fatal_f("sshbuf_new failed"); if ((r = sshbuf_put_u8(msg, SSH2_AGENT_IDENTITIES_ANSWER)) != 0 || @@ -427,6 +430,7 @@ struct sshkey *key = NULL; Identity *id; + debug2_f("entering"); if ((r = sshkey_froms(e->request, &key)) != 0) { error_fr(r, "parse key"); goto done; @@ -452,6 +456,7 @@ { Identity *id; + debug2_f("entering"); /* Loop over all identities and clear the keys. */ for (id = TAILQ_FIRST(&idtab->idlist); id; id = TAILQ_FIRST(&idtab->idlist)) { @@ -505,6 +510,7 @@ u_char ctype; int r = SSH_ERR_INTERNAL_ERROR; + debug2_f("entering"); if ((r = sshkey_private_deserialize(e->request, &k)) != 0 || k == NULL || (r = sshbuf_get_cstring(e->request, &comment, NULL)) != 0) { @@ -646,6 +652,7 @@ static u_int fail_count = 0; size_t pwlen; + debug2_f("entering"); /* * This is deliberately fatal: the user has requested that we lock, * but we can't parse their request properly. The only safe thing to @@ -716,6 +723,7 @@ struct sshkey **keys = NULL, *k; Identity *id; + debug2_f("entering"); if ((r = sshbuf_get_cstring(e->request, &provider, NULL)) != 0 || (r = sshbuf_get_cstring(e->request, &pin, NULL)) != 0) { error_fr(r, "parse"); @@ -795,6 +803,7 @@ int r, success = 0; Identity *id, *nxt; + debug2_f("entering"); if ((r = sshbuf_get_cstring(e->request, &provider, NULL)) != 0 || (r = sshbuf_get_cstring(e->request, &pin, NULL)) != 0) { error_fr(r, "parse"); @@ -937,6 +946,8 @@ { u_int i, old_alloc, new_alloc; + debug_f("type = %s", type == AUTH_CONNECTION ? "CONNECTION" : + (type == AUTH_SOCKET ? "SOCKET" : "UNKNOWN")); set_nonblock(fd); if (fd > max_fd) @@ -954,7 +965,8 @@ } old_alloc = sockets_alloc; new_alloc = sockets_alloc + 10; - sockets = xreallocarray(sockets, new_alloc, sizeof(sockets[0])); + sockets = xrecallocarray(sockets, old_alloc, new_alloc, + sizeof(sockets[0])); for (i = old_alloc; i < new_alloc; i++) sockets[i].type = AUTH_UNUSED; sockets_alloc = new_alloc;