summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2013-03-20 23:13:19 +0800
committerMatt Johnston <matt@ucc.asn.au>2013-03-20 23:13:19 +0800
commite5f76715968e5a20936c4c596cb1097dac3c6852 (patch)
treef96678eaa9f77dc2c2a05c2827320ec75e3f9245
parentf6122d4fdd79f46ce8431813cc26b07424ce49b0 (diff)
downloaddropbear-e5f76715968e5a20936c4c596cb1097dac3c6852.tar.gz
Fix "-m none" case where an entire packet fits in a block and can be
read by read_packet_init()
-rw-r--r--packet.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/packet.c b/packet.c
index 349ed40..f979cae 100644
--- a/packet.c
+++ b/packet.c
@@ -133,22 +133,29 @@ void read_packet() {
/* Attempt to read the remainder of the packet, note that there
* mightn't be any available (EAGAIN) */
maxlen = ses.readbuf->len - ses.readbuf->pos;
- len = read(ses.sock_in, buf_getptr(ses.readbuf, maxlen), maxlen);
+ if (maxlen == 0) {
+ /* Occurs when the packet is only a single block long and has all
+ * been read in read_packet_init(). Usually means that MAC is disabled
+ */
+ len = 0;
+ } else {
+ len = read(ses.sock_in, buf_getptr(ses.readbuf, maxlen), maxlen);
- if (len == 0) {
- ses.remoteclosed();
- }
+ if (len == 0) {
+ ses.remoteclosed();
+ }
- if (len < 0) {
- if (errno == EINTR || errno == EAGAIN) {
- TRACE(("leave read_packet: EINTR or EAGAIN"))
- return;
- } else {
- dropbear_exit("Error reading: %s", strerror(errno));
+ if (len < 0) {
+ if (errno == EINTR || errno == EAGAIN) {
+ TRACE(("leave read_packet: EINTR or EAGAIN"))
+ return;
+ } else {
+ dropbear_exit("Error reading: %s", strerror(errno));
+ }
}
- }
- buf_incrpos(ses.readbuf, len);
+ buf_incrpos(ses.readbuf, len);
+ }
if ((unsigned int)len == maxlen) {
/* The whole packet has been read */