diff options
Diffstat (limited to 'ssh-agent.c')
-rw-r--r-- | ssh-agent.c | 15 |
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) | |||
767 | static void | 767 | static void |
768 | new_socket(sock_type type, int fd) | 768 | new_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 | ||
802 | static int | 803 | static int |