summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-03-05 07:07:49 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-03-05 07:07:49 +0000
commitcb978aa057b1e36a2ac6e738cc055a70c6c48fd8 (patch)
tree63fccb3ae8a44db98439b5cb1fed12d862d6ac99
parentcb80bdf6d5c2e232e751187f86b6fa68d959fcf9 (diff)
- millert@cvs.openbsd.org 2001/03/03 21:41:07
[packet.c] Dynamically allocate fd_set; deraadt@ OK
-rw-r--r--ChangeLog5
-rw-r--r--packet.c32
2 files changed, 25 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 13dc9bef5..5b27784ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -131,6 +131,9 @@
131 - millert@cvs.openbsd.org 2001/03/03 21:40:30 131 - millert@cvs.openbsd.org 2001/03/03 21:40:30
132 [sftp-server.c] 132 [sftp-server.c]
133 Dynamically allocate fd_set; deraadt@ OK 133 Dynamically allocate fd_set; deraadt@ OK
134 - millert@cvs.openbsd.org 2001/03/03 21:41:07
135 [packet.c]
136 Dynamically allocate fd_set; deraadt@ OK
134 137
13520010304 13820010304
136 - (bal) Remove make-ssh-known-hosts.1 since it's no longer valid. 139 - (bal) Remove make-ssh-known-hosts.1 since it's no longer valid.
@@ -4323,4 +4326,4 @@
4323 - Wrote replacements for strlcpy and mkdtemp 4326 - Wrote replacements for strlcpy and mkdtemp
4324 - Released 1.0pre1 4327 - Released 1.0pre1
4325 4328
4326$Id: ChangeLog,v 1.891 2001/03/05 07:06:12 mouring Exp $ 4329$Id: ChangeLog,v 1.892 2001/03/05 07:07:49 mouring Exp $
diff --git a/packet.c b/packet.c
index 419b2f777..1a634cff4 100644
--- a/packet.c
+++ b/packet.c
@@ -37,7 +37,7 @@
37 */ 37 */
38 38
39#include "includes.h" 39#include "includes.h"
40RCSID("$OpenBSD: packet.c,v 1.55 2001/03/01 02:45:10 deraadt Exp $"); 40RCSID("$OpenBSD: packet.c,v 1.56 2001/03/03 21:41:07 millert Exp $");
41 41
42#include "xmalloc.h" 42#include "xmalloc.h"
43#include "buffer.h" 43#include "buffer.h"
@@ -660,10 +660,13 @@ int
660packet_read(int *payload_len_ptr) 660packet_read(int *payload_len_ptr)
661{ 661{
662 int type, len; 662 int type, len;
663 fd_set set; 663 fd_set *setp;
664 char buf[8192]; 664 char buf[8192];
665 DBG(debug("packet_read()")); 665 DBG(debug("packet_read()"));
666 666
667 setp = (fd_set *)xmalloc(howmany(connection_in+1, NFDBITS) *
668 sizeof(fd_mask));
669
667 /* Since we are blocking, ensure that all written packets have been sent. */ 670 /* Since we are blocking, ensure that all written packets have been sent. */
668 packet_write_wait(); 671 packet_write_wait();
669 672
@@ -678,17 +681,20 @@ packet_read(int *payload_len_ptr)
678 || type == SSH_CMSG_EXIT_CONFIRMATION)) 681 || type == SSH_CMSG_EXIT_CONFIRMATION))
679 packet_integrity_check(*payload_len_ptr, 0, type); 682 packet_integrity_check(*payload_len_ptr, 0, type);
680 /* If we got a packet, return it. */ 683 /* If we got a packet, return it. */
681 if (type != SSH_MSG_NONE) 684 if (type != SSH_MSG_NONE) {
685 xfree(setp);
682 return type; 686 return type;
687 }
683 /* 688 /*
684 * Otherwise, wait for some data to arrive, add it to the 689 * Otherwise, wait for some data to arrive, add it to the
685 * buffer, and try again. 690 * buffer, and try again.
686 */ 691 */
687 FD_ZERO(&set); 692 memset(setp, 0, howmany(connection_in + 1, NFDBITS) *
688 FD_SET(connection_in, &set); 693 sizeof(fd_mask));
694 FD_SET(connection_in, setp);
689 695
690 /* Wait for some data to arrive. */ 696 /* Wait for some data to arrive. */
691 while (select(connection_in + 1, &set, NULL, NULL, NULL) == -1 && 697 while (select(connection_in + 1, setp, NULL, NULL, NULL) == -1 &&
692 (errno == EAGAIN || errno == EINTR)) 698 (errno == EAGAIN || errno == EINTR))
693 ; 699 ;
694 700
@@ -1194,17 +1200,21 @@ packet_write_poll()
1194void 1200void
1195packet_write_wait() 1201packet_write_wait()
1196{ 1202{
1203 fd_set *setp;
1204
1205 setp = (fd_set *)xmalloc(howmany(connection_out + 1, NFDBITS) *
1206 sizeof(fd_mask));
1197 packet_write_poll(); 1207 packet_write_poll();
1198 while (packet_have_data_to_write()) { 1208 while (packet_have_data_to_write()) {
1199 fd_set set; 1209 memset(setp, 0, howmany(connection_out + 1, NFDBITS) *
1200 1210 sizeof(fd_mask));
1201 FD_ZERO(&set); 1211 FD_SET(connection_out, setp);
1202 FD_SET(connection_out, &set); 1212 while (select(connection_out + 1, NULL, setp, NULL, NULL) == -1 &&
1203 while (select(connection_out + 1, NULL, &set, NULL, NULL) == -1 &&
1204 (errno == EAGAIN || errno == EINTR)) 1213 (errno == EAGAIN || errno == EINTR))
1205 ; 1214 ;
1206 packet_write_poll(); 1215 packet_write_poll();
1207 } 1216 }
1217 xfree(setp);
1208} 1218}
1209 1219
1210/* Returns true if there is buffered data to write to the connection. */ 1220/* Returns true if there is buffered data to write to the connection. */