www.libssh2.org | Daily snapshots | Mailing list archive | Docs | Examples | github

Archive Index This month's Index

Subject: [PATCH] do decompression only if needed

[PATCH] do decompression only if needed

From: Alfred Gebert <alfred.gebert_at_gmail.com>
Date: Wed, 26 Jan 2011 17:56:42 +0100

The buffer for the decompression (remote.comp_abstract) is
initialised in time when it is needed.
With this fix decompression is disabled when the buffer
(remote.comp_abstract) is not initialised.

Bug: http://trac.libssh2.org/ticket/200

---
 src/transport.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
This patch fixes bug #200 for me. Tested with JSCAPE sftp server.
diff --git a/src/transport.c b/src/transport.c
index 38e005a..c519f0a 100644
--- a/src/transport.c
+++ b/src/transport.c
@@ -199,7 +199,10 @@ fullpacket(LIBSSH2_SESSION * session, int
encrypted /* 1 or 0 */ )
         session->fullpacket_payload_len -= p->padding_length;
         /* Check for and deal with decompression */
-        if (session->remote.comp && session->remote.comp->compress) {
+        if (session->remote.comp &&
+            session->remote.comp->compress &&
+            session->remote.comp_abstract)
+        {
             unsigned char *data;
             size_t data_len;
             rc = session->remote.comp->decomp(session,
@@ -215,7 +218,6 @@ fullpacket(LIBSSH2_SESSION * session, int
encrypted /* 1 or 0 */ )
             p->payload = data;
             session->fullpacket_payload_len = data_len;
         }
-
         session->fullpacket_packet_type = p->payload[0];
         debugdump(session, "libssh2_transport_read() plain",
-- 
1.7.3.1.msysgit.0
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2011-01-26

the libssh2 team