comparison packet.c @ 241:c5d3ef11155f

* use own assertions which should get logged properly
author Matt Johnston <matt@ucc.asn.au>
date Mon, 05 Sep 2005 15:16:10 +0000
parents cbf1165d9386
children 695413c59b6a
comparison
equal deleted inserted replaced
238:e923801a7678 241:c5d3ef11155f
51 51
52 int len, written; 52 int len, written;
53 buffer * writebuf = NULL; 53 buffer * writebuf = NULL;
54 54
55 TRACE(("enter write_packet")) 55 TRACE(("enter write_packet"))
56 assert(!isempty(&ses.writequeue)); 56 dropbear_assert(!isempty(&ses.writequeue));
57 57
58 /* Get the next buffer in the queue of encrypted packets to write*/ 58 /* Get the next buffer in the queue of encrypted packets to write*/
59 writebuf = (buffer*)examine(&ses.writequeue); 59 writebuf = (buffer*)examine(&ses.writequeue);
60 60
61 len = writebuf->len - writebuf->pos; 61 len = writebuf->len - writebuf->pos;
62 assert(len > 0); 62 dropbear_assert(len > 0);
63 /* Try to write as much as possible */ 63 /* Try to write as much as possible */
64 written = write(ses.sock, buf_getptr(writebuf, len), len); 64 written = write(ses.sock, buf_getptr(writebuf, len), len);
65 65
66 if (written < 0) { 66 if (written < 0) {
67 if (errno == EINTR) { 67 if (errno == EINTR) {
116 } 116 }
117 } 117 }
118 118
119 /* Attempt to read the remainder of the packet, note that there 119 /* Attempt to read the remainder of the packet, note that there
120 * mightn't be any available (EAGAIN) */ 120 * mightn't be any available (EAGAIN) */
121 assert(ses.readbuf != NULL); 121 dropbear_assert(ses.readbuf != NULL);
122 maxlen = ses.readbuf->len - ses.readbuf->pos; 122 maxlen = ses.readbuf->len - ses.readbuf->pos;
123 len = read(ses.sock, buf_getptr(ses.readbuf, maxlen), maxlen); 123 len = read(ses.sock, buf_getptr(ses.readbuf, maxlen), maxlen);
124 124
125 if (len == 0) { 125 if (len == 0) {
126 ses.remoteclosed(); 126 ses.remoteclosed();
160 macsize = ses.keys->recv_algo_mac->hashsize; 160 macsize = ses.keys->recv_algo_mac->hashsize;
161 161
162 if (ses.readbuf == NULL) { 162 if (ses.readbuf == NULL) {
163 /* start of a new packet */ 163 /* start of a new packet */
164 ses.readbuf = buf_new(INIT_READBUF); 164 ses.readbuf = buf_new(INIT_READBUF);
165 assert(ses.decryptreadbuf == NULL); 165 dropbear_assert(ses.decryptreadbuf == NULL);
166 ses.decryptreadbuf = buf_new(blocksize); 166 ses.decryptreadbuf = buf_new(blocksize);
167 } 167 }
168 168
169 maxlen = blocksize - ses.readbuf->pos; 169 maxlen = blocksize - ses.readbuf->pos;
170 170
598 598
599 if (ses.keys->trans_zstream->avail_in == 0) { 599 if (ses.keys->trans_zstream->avail_in == 0) {
600 break; 600 break;
601 } 601 }
602 602
603 assert(ses.keys->trans_zstream->avail_out == 0); 603 dropbear_assert(ses.keys->trans_zstream->avail_out == 0);
604 604
605 /* the buffer has been filled, we must extend. This only happens in 605 /* the buffer has been filled, we must extend. This only happens in
606 * unusual circumstances where the data grows in size after deflate(), 606 * unusual circumstances where the data grows in size after deflate(),
607 * but it is possible */ 607 * but it is possible */
608 buf_resize(dest, dest->size + ZLIB_COMPRESS_INCR); 608 buf_resize(dest, dest->size + ZLIB_COMPRESS_INCR);