comparison packet.c @ 711:f4232b65b316

Fix "-m none" case where an entire packet fits in a block and can be read by read_packet_init()
author Matt Johnston <matt@ucc.asn.au>
date Wed, 20 Mar 2013 23:13:19 +0800
parents 895fbe068f2c
children f27058078d61
comparison
equal deleted inserted replaced
710:91dd8328a3ff 711:f4232b65b316
131 } 131 }
132 132
133 /* Attempt to read the remainder of the packet, note that there 133 /* Attempt to read the remainder of the packet, note that there
134 * mightn't be any available (EAGAIN) */ 134 * mightn't be any available (EAGAIN) */
135 maxlen = ses.readbuf->len - ses.readbuf->pos; 135 maxlen = ses.readbuf->len - ses.readbuf->pos;
136 len = read(ses.sock_in, buf_getptr(ses.readbuf, maxlen), maxlen); 136 if (maxlen == 0) {
137 137 /* Occurs when the packet is only a single block long and has all
138 if (len == 0) { 138 * been read in read_packet_init(). Usually means that MAC is disabled
139 ses.remoteclosed(); 139 */
140 } 140 len = 0;
141 141 } else {
142 if (len < 0) { 142 len = read(ses.sock_in, buf_getptr(ses.readbuf, maxlen), maxlen);
143 if (errno == EINTR || errno == EAGAIN) { 143
144 TRACE(("leave read_packet: EINTR or EAGAIN")) 144 if (len == 0) {
145 return; 145 ses.remoteclosed();
146 } else { 146 }
147 dropbear_exit("Error reading: %s", strerror(errno)); 147
148 } 148 if (len < 0) {
149 } 149 if (errno == EINTR || errno == EAGAIN) {
150 150 TRACE(("leave read_packet: EINTR or EAGAIN"))
151 buf_incrpos(ses.readbuf, len); 151 return;
152 } else {
153 dropbear_exit("Error reading: %s", strerror(errno));
154 }
155 }
156
157 buf_incrpos(ses.readbuf, len);
158 }
152 159
153 if ((unsigned int)len == maxlen) { 160 if ((unsigned int)len == maxlen) {
154 /* The whole packet has been read */ 161 /* The whole packet has been read */
155 decrypt_packet(); 162 decrypt_packet();
156 /* The main select() loop process_packet() to 163 /* The main select() loop process_packet() to