summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2015-03-01 00:57:21 +0800
committerMatt Johnston <matt@ucc.asn.au>2015-03-01 00:57:21 +0800
commite65c9c75dc0efb9bbf8f7e292e4ba5532e31ae81 (patch)
treedfcc10546a64f523ab760ee08f0cfb2a0056d696
parent8b562aec18e068fb233cba8826a7a398e9157815 (diff)
downloaddropbear-e65c9c75dc0efb9bbf8f7e292e4ba5532e31ae81.tar.gz
A bit of a bodge to avoid memcpy if zlib is disabled
-rw-r--r--common-kex.c12
-rw-r--r--packet.c15
-rw-r--r--session.h1
3 files changed, 18 insertions, 10 deletions
diff --git a/common-kex.c b/common-kex.c
index f355560..0e477da 100644
--- a/common-kex.c
+++ b/common-kex.c
@@ -534,8 +534,10 @@ void recv_msg_kexinit() {
buf_putstring(ses.kexhashbuf,
ses.transkexinit->data, ses.transkexinit->len);
/* I_S, the payload of the server's SSH_MSG_KEXINIT */
- buf_setpos(ses.payload, 0);
- buf_putstring(ses.kexhashbuf, ses.payload->data, ses.payload->len);
+ buf_setpos(ses.payload, ses.payload_beginning);
+ buf_putstring(ses.kexhashbuf,
+ buf_getptr(ses.payload, ses.payload->len-ses.payload->pos),
+ ses.payload->len-ses.payload->pos);
ses.requirenext = SSH_MSG_KEXDH_REPLY;
} else {
/* SERVER */
@@ -549,8 +551,10 @@ void recv_msg_kexinit() {
(unsigned char*)LOCAL_IDENT, local_ident_len);
/* I_C, the payload of the client's SSH_MSG_KEXINIT */
- buf_setpos(ses.payload, 0);
- buf_putstring(ses.kexhashbuf, ses.payload->data, ses.payload->len);
+ buf_setpos(ses.payload, ses.payload_beginning);
+ buf_putstring(ses.kexhashbuf,
+ buf_getptr(ses.payload, ses.payload->len-ses.payload->pos),
+ ses.payload->len-ses.payload->pos);
/* I_S, the payload of the server's SSH_MSG_KEXINIT */
buf_putstring(ses.kexhashbuf,
diff --git a/packet.c b/packet.c
index b477a07..d38d8f4 100644
--- a/packet.c
+++ b/packet.c
@@ -314,18 +314,21 @@ void decrypt_packet() {
if (is_compress_recv()) {
/* decompress */
ses.payload = buf_decompress(ses.readbuf, len);
+ buf_setpos(ses.payload, 0);
+ ses.payload_beginning = 0;
+ buf_free(ses.readbuf);
} else
#endif
{
+ ses.payload = ses.readbuf;
+ ses.payload_beginning = ses.payload->pos;
+ buf_setlen(ses.payload, ses.payload->pos + len);
/* copy payload */
- ses.payload = buf_new(len);
- memcpy(ses.payload->data, buf_getptr(ses.readbuf, len), len);
- buf_incrlen(ses.payload, len);
+ //ses.payload = buf_new(len);
+ //memcpy(ses.payload->data, buf_getptr(ses.readbuf, len), len);
+ //buf_incrlen(ses.payload, len);
}
-
- buf_free(ses.readbuf);
ses.readbuf = NULL;
- buf_setpos(ses.payload, 0);
ses.recvseq++;
diff --git a/session.h b/session.h
index 85dba3b..0780d51 100644
--- a/session.h
+++ b/session.h
@@ -127,6 +127,7 @@ struct sshsession {
struct Queue writequeue; /* A queue of encrypted packets to send */
buffer *readbuf; /* From the wire, decrypted in-place */
buffer *payload; /* Post-decompression, the actual SSH packet */
+ unsigned int payload_beginning;
unsigned int transseq, recvseq; /* Sequence IDs */
/* Packet-handling flags */