summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--sftp-server.c24
2 files changed, 18 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 512343f7a..13dc9bef5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -128,6 +128,9 @@
128 [ssh-keyscan.c] 128 [ssh-keyscan.c]
129 Dynamically allocate read_wait and its copies. Since maxfd is 129 Dynamically allocate read_wait and its copies. Since maxfd is
130 based on resource limits it is often (usually?) larger than FD_SETSIZE. 130 based on resource limits it is often (usually?) larger than FD_SETSIZE.
131 - millert@cvs.openbsd.org 2001/03/03 21:40:30
132 [sftp-server.c]
133 Dynamically allocate fd_set; deraadt@ OK
131 134
13220010304 13520010304
133 - (bal) Remove make-ssh-known-hosts.1 since it's no longer valid. 136 - (bal) Remove make-ssh-known-hosts.1 since it's no longer valid.
@@ -4320,4 +4323,4 @@
4320 - Wrote replacements for strlcpy and mkdtemp 4323 - Wrote replacements for strlcpy and mkdtemp
4321 - Released 1.0pre1 4324 - Released 1.0pre1
4322 4325
4323$Id: ChangeLog,v 1.890 2001/03/05 07:04:38 mouring Exp $ 4326$Id: ChangeLog,v 1.891 2001/03/05 07:06:12 mouring Exp $
diff --git a/sftp-server.c b/sftp-server.c
index c8daeea1e..2b1a7e3e5 100644
--- a/sftp-server.c
+++ b/sftp-server.c
@@ -22,7 +22,7 @@
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */ 23 */
24#include "includes.h" 24#include "includes.h"
25RCSID("$OpenBSD: sftp-server.c,v 1.20 2001/02/21 09:12:56 deraadt Exp $"); 25RCSID("$OpenBSD: sftp-server.c,v 1.21 2001/03/03 21:40:30 millert Exp $");
26 26
27#include "buffer.h" 27#include "buffer.h"
28#include "bufaux.h" 28#include "bufaux.h"
@@ -940,9 +940,9 @@ process(void)
940int 940int
941main(int ac, char **av) 941main(int ac, char **av)
942{ 942{
943 fd_set rset, wset; 943 fd_set *rset, *wset;
944 int in, out, max; 944 int in, out, max;
945 ssize_t len, olen; 945 ssize_t len, olen, set_size;
946 946
947 __progname = get_progname(av[0]); 947 __progname = get_progname(av[0]);
948 handle_init(); 948 handle_init();
@@ -963,23 +963,27 @@ main(int ac, char **av)
963 buffer_init(&iqueue); 963 buffer_init(&iqueue);
964 buffer_init(&oqueue); 964 buffer_init(&oqueue);
965 965
966 set_size = howmany(max + 1, NFDBITS) * sizeof(fd_mask);
967 rset = (fd_set *)xmalloc(set_size);
968 wset = (fd_set *)xmalloc(set_size);
969
966 for (;;) { 970 for (;;) {
967 FD_ZERO(&rset); 971 memset(rset, 0, set_size);
968 FD_ZERO(&wset); 972 memset(wset, 0, set_size);
969 973
970 FD_SET(in, &rset); 974 FD_SET(in, rset);
971 olen = buffer_len(&oqueue); 975 olen = buffer_len(&oqueue);
972 if (olen > 0) 976 if (olen > 0)
973 FD_SET(out, &wset); 977 FD_SET(out, wset);
974 978
975 if (select(max+1, &rset, &wset, NULL, NULL) < 0) { 979 if (select(max+1, rset, wset, NULL, NULL) < 0) {
976 if (errno == EINTR) 980 if (errno == EINTR)
977 continue; 981 continue;
978 exit(2); 982 exit(2);
979 } 983 }
980 984
981 /* copy stdin to iqueue */ 985 /* copy stdin to iqueue */
982 if (FD_ISSET(in, &rset)) { 986 if (FD_ISSET(in, rset)) {
983 char buf[4*4096]; 987 char buf[4*4096];
984 len = read(in, buf, sizeof buf); 988 len = read(in, buf, sizeof buf);
985 if (len == 0) { 989 if (len == 0) {
@@ -993,7 +997,7 @@ main(int ac, char **av)
993 } 997 }
994 } 998 }
995 /* send oqueue to stdout */ 999 /* send oqueue to stdout */
996 if (FD_ISSET(out, &wset)) { 1000 if (FD_ISSET(out, wset)) {
997 len = write(out, buffer_ptr(&oqueue), olen); 1001 len = write(out, buffer_ptr(&oqueue), olen);
998 if (len < 0) { 1002 if (len < 0) {
999 error("write error"); 1003 error("write error");