[sftp-server.c]
     Dynamically allocate fd_set; deraadt@ OK
This commit is contained in:
Ben Lindstrom 2001-03-05 07:06:12 +00:00
parent c1e0421cb4
commit cb80bdf6d5
2 changed files with 19 additions and 12 deletions

View File

@ -128,6 +128,9 @@
[ssh-keyscan.c]
Dynamically allocate read_wait and its copies. Since maxfd is
based on resource limits it is often (usually?) larger than FD_SETSIZE.
- millert@cvs.openbsd.org 2001/03/03 21:40:30
[sftp-server.c]
Dynamically allocate fd_set; deraadt@ OK
20010304
- (bal) Remove make-ssh-known-hosts.1 since it's no longer valid.
@ -4320,4 +4323,4 @@
- Wrote replacements for strlcpy and mkdtemp
- Released 1.0pre1
$Id: ChangeLog,v 1.890 2001/03/05 07:04:38 mouring Exp $
$Id: ChangeLog,v 1.891 2001/03/05 07:06:12 mouring Exp $

View File

@ -22,7 +22,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "includes.h"
RCSID("$OpenBSD: sftp-server.c,v 1.20 2001/02/21 09:12:56 deraadt Exp $");
RCSID("$OpenBSD: sftp-server.c,v 1.21 2001/03/03 21:40:30 millert Exp $");
#include "buffer.h"
#include "bufaux.h"
@ -940,9 +940,9 @@ process(void)
int
main(int ac, char **av)
{
fd_set rset, wset;
fd_set *rset, *wset;
int in, out, max;
ssize_t len, olen;
ssize_t len, olen, set_size;
__progname = get_progname(av[0]);
handle_init();
@ -963,23 +963,27 @@ main(int ac, char **av)
buffer_init(&iqueue);
buffer_init(&oqueue);
for (;;) {
FD_ZERO(&rset);
FD_ZERO(&wset);
set_size = howmany(max + 1, NFDBITS) * sizeof(fd_mask);
rset = (fd_set *)xmalloc(set_size);
wset = (fd_set *)xmalloc(set_size);
FD_SET(in, &rset);
for (;;) {
memset(rset, 0, set_size);
memset(wset, 0, set_size);
FD_SET(in, rset);
olen = buffer_len(&oqueue);
if (olen > 0)
FD_SET(out, &wset);
FD_SET(out, wset);
if (select(max+1, &rset, &wset, NULL, NULL) < 0) {
if (select(max+1, rset, wset, NULL, NULL) < 0) {
if (errno == EINTR)
continue;
exit(2);
}
/* copy stdin to iqueue */
if (FD_ISSET(in, &rset)) {
if (FD_ISSET(in, rset)) {
char buf[4*4096];
len = read(in, buf, sizeof buf);
if (len == 0) {
@ -993,7 +997,7 @@ main(int ac, char **av)
}
}
/* send oqueue to stdout */
if (FD_ISSET(out, &wset)) {
if (FD_ISSET(out, wset)) {
len = write(out, buffer_ptr(&oqueue), olen);
if (len < 0) {
error("write error");