summaryrefslogtreecommitdiff
path: root/ssh-agent.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2003-09-19 09:29:59 +0000
committerColin Watson <cjwatson@debian.org>2003-09-19 09:29:59 +0000
commit9dcbace70ec41ea21cd291e70bf6fd1bbd255a9e (patch)
tree4f3eaf0a295bfcf24e4c45bfce929b870d393ebf /ssh-agent.c
parent9784e8f89704e17080b2d42ceeeef54ae73d51dd (diff)
Merge even more buffer allocation fixes from upstream (CAN-2003-0682,
#211434).
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