1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-08-08 19:02:06 +03:00

packet: Don't (de)compress empty buffers.

This fixes bug #50.
This commit is contained in:
Andreas Schneider
2011-06-11 10:51:38 +02:00
parent 981190f8d3
commit fb0f125351

View File

@@ -256,7 +256,9 @@ int ssh_packet_socket_callback(const void *data, size_t receivedlen, void *user)
"After padding, %d bytes left in buffer", "After padding, %d bytes left in buffer",
buffer_get_rest_len(session->in_buffer)); buffer_get_rest_len(session->in_buffer));
#if defined(HAVE_LIBZ) && defined(WITH_LIBZ) #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 ..."); ssh_log(session, SSH_LOG_PACKET, "Decompressing in_buffer ...");
if (decompress_buffer(session, session->in_buffer,MAX_PACKET_LEN) < 0) { if (decompress_buffer(session, session->in_buffer,MAX_PACKET_LEN) < 0) {
goto error; goto error;
@@ -459,7 +461,9 @@ static int packet_send2(ssh_session session) {
"Writing on the wire a packet having %u bytes before", currentlen); "Writing on the wire a packet having %u bytes before", currentlen);
#if defined(HAVE_LIBZ) && defined(WITH_LIBZ) #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 ..."); ssh_log(session, SSH_LOG_PACKET, "Compressing out_buffer ...");
if (compress_buffer(session,session->out_buffer) < 0) { if (compress_buffer(session,session->out_buffer) < 0) {
goto error; goto error;