diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2011-06-11 10:51:38 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2011-06-11 13:15:46 +0200 |
commit | fb0f1253519d5ff76fac1f0fc84077541ca93033 (patch) | |
tree | 971f676af2247254d234a433c3c270065cbb7429 /src/packet.c | |
parent | 981190f8d3f5a24c321ec6d00ed2731088c031df (diff) | |
download | libssh-fb0f1253519d5ff76fac1f0fc84077541ca93033.tar.gz libssh-fb0f1253519d5ff76fac1f0fc84077541ca93033.tar.xz libssh-fb0f1253519d5ff76fac1f0fc84077541ca93033.zip |
packet: Don't (de)compress empty buffers.
This fixes bug #50.
Diffstat (limited to 'src/packet.c')
-rw-r--r-- | src/packet.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/packet.c b/src/packet.c index a670b693..1bfbae1f 100644 --- a/src/packet.c +++ b/src/packet.c @@ -256,7 +256,9 @@ int ssh_packet_socket_callback(const void *data, size_t receivedlen, void *user) "After padding, %d bytes left in buffer", buffer_get_rest_len(session->in_buffer)); #if defined(HAVE_LIBZ) && defined(WITH_LIBZ) - if (session->current_crypto && session->current_crypto->do_compress_in) { + if (session->current_crypto + && session->current_crypto->do_compress_in + && buffer_get_rest_len(session->in_buffer)) { ssh_log(session, SSH_LOG_PACKET, "Decompressing in_buffer ..."); if (decompress_buffer(session, session->in_buffer,MAX_PACKET_LEN) < 0) { goto error; @@ -459,7 +461,9 @@ static int packet_send2(ssh_session session) { "Writing on the wire a packet having %u bytes before", currentlen); #if defined(HAVE_LIBZ) && defined(WITH_LIBZ) - if (session->current_crypto && session->current_crypto->do_compress_out) { + if (session->current_crypto + && session->current_crypto->do_compress_out + && buffer_get_rest_len(session->out_buffer)) { ssh_log(session, SSH_LOG_PACKET, "Compressing out_buffer ..."); if (compress_buffer(session,session->out_buffer) < 0) { goto error; |