summaryrefslogtreecommitdiff
path: root/ssh-agent.c
diff options
context:
space:
mode:
Diffstat (limited to 'ssh-agent.c')
-rw-r--r--ssh-agent.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/ssh-agent.c b/ssh-agent.c
index eb593de73..a936134fe 100644
--- a/ssh-agent.c
+++ b/ssh-agent.c
@@ -767,7 +767,7 @@ process_message(SocketEntry *e)
767static void 767static void
768new_socket(sock_type type, int fd) 768new_socket(sock_type type, int fd)
769{ 769{
770 u_int i, old_alloc; 770 u_int i, old_alloc, new_alloc;
771 771
772 if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) 772 if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0)
773 error("fcntl O_NONBLOCK: %s", strerror(errno)); 773 error("fcntl O_NONBLOCK: %s", strerror(errno));
@@ -778,25 +778,26 @@ new_socket(sock_type type, int fd)
778 for (i = 0; i < sockets_alloc; i++) 778 for (i = 0; i < sockets_alloc; i++)
779 if (sockets[i].type == AUTH_UNUSED) { 779 if (sockets[i].type == AUTH_UNUSED) {
780 sockets[i].fd = fd; 780 sockets[i].fd = fd;
781 sockets[i].type = type;
782 buffer_init(&sockets[i].input); 781 buffer_init(&sockets[i].input);
783 buffer_init(&sockets[i].output); 782 buffer_init(&sockets[i].output);
784 buffer_init(&sockets[i].request); 783 buffer_init(&sockets[i].request);
784 sockets[i].type = type;
785 return; 785 return;
786 } 786 }
787 old_alloc = sockets_alloc; 787 old_alloc = sockets_alloc;
788 sockets_alloc += 10; 788 new_alloc = sockets_alloc + 10;
789 if (sockets) 789 if (sockets)
790 sockets = xrealloc(sockets, sockets_alloc * sizeof(sockets[0])); 790 sockets = xrealloc(sockets, new_alloc * sizeof(sockets[0]));
791 else 791 else
792 sockets = xmalloc(sockets_alloc * sizeof(sockets[0])); 792 sockets = xmalloc(new_alloc * sizeof(sockets[0]));
793 for (i = old_alloc; i < sockets_alloc; i++) 793 for (i = old_alloc; i < new_alloc; i++)
794 sockets[i].type = AUTH_UNUSED; 794 sockets[i].type = AUTH_UNUSED;
795 sockets[old_alloc].type = type; 795 sockets_alloc = new_alloc;
796 sockets[old_alloc].fd = fd; 796 sockets[old_alloc].fd = fd;
797 buffer_init(&sockets[old_alloc].input); 797 buffer_init(&sockets[old_alloc].input);
798 buffer_init(&sockets[old_alloc].output); 798 buffer_init(&sockets[old_alloc].output);
799 buffer_init(&sockets[old_alloc].request); 799 buffer_init(&sockets[old_alloc].request);
800 sockets[old_alloc].type = type;
800} 801}
801 802
802static int 803static int