diff options
author | Colin Watson <cjwatson@debian.org> | 2003-09-19 09:29:59 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2003-09-19 09:29:59 +0000 |
commit | 9dcbace70ec41ea21cd291e70bf6fd1bbd255a9e (patch) | |
tree | 4f3eaf0a295bfcf24e4c45bfce929b870d393ebf /ssh-agent.c | |
parent | 9784e8f89704e17080b2d42ceeeef54ae73d51dd (diff) |
Merge even more buffer allocation fixes from upstream (CAN-2003-0682,
#211434).
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 |