diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9096cbce..e0243bb0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -91,6 +91,7 @@ set(libssh_SRCS ecdh.c error.c getpass.c + gzip.c init.c kdf.c kex.c @@ -252,13 +253,6 @@ if (WITH_GEX) ) endif (WITH_GEX) -if (WITH_ZLIB) - set(libssh_SRCS - ${libssh_SRCS} - gzip.c - ) -endif(WITH_ZLIB) - if (WITH_GSSAPI AND GSSAPI_FOUND) set(libssh_SRCS ${libssh_SRCS} diff --git a/src/gzip.c b/src/gzip.c index 27c8042b..e814080a 100644 --- a/src/gzip.c +++ b/src/gzip.c @@ -26,13 +26,15 @@ #include #include -#include #include "libssh/buffer.h" #include "libssh/crypto.h" #include "libssh/priv.h" #include "libssh/session.h" +#ifdef WITH_ZLIB +#include + #ifndef BLOCKSIZE #define BLOCKSIZE 4092 #endif @@ -274,3 +276,27 @@ compress_cleanup(struct ssh_crypto_struct *crypto) } SAFE_FREE(crypto->compress_in_ctx); } +#else /* WITH_ZLIB */ + +int +compress_buffer(UNUSED_PARAM(ssh_session session), UNUSED_PARAM(ssh_buffer buf)) +{ + /* without zlib compiled in, this should never happen */ + return -1; +} +int +decompress_buffer(UNUSED_PARAM(ssh_session session), + UNUSED_PARAM(ssh_buffer buf), + UNUSED_PARAM(size_t maxlen)) +{ + /* without zlib compiled in, this should never happen */ + return -1; +} + +void +compress_cleanup(UNUSED_PARAM(struct ssh_crypto_struct *crypto)) +{ + /* no-op */ +} + +#endif /* WITH_ZLIB */ diff --git a/src/packet.c b/src/packet.c index ed9c13fb..83257fe5 100644 --- a/src/packet.c +++ b/src/packet.c @@ -1303,7 +1303,6 @@ ssh_packet_socket_callback(const void *data, size_t receivedlen, void *user) ssh_buffer_pass_bytes_end(session->in_buffer, padding); compsize = ssh_buffer_get_len(session->in_buffer); -#ifdef WITH_ZLIB if (crypto && crypto->do_compress_in && ssh_buffer_get_len(session->in_buffer) > 0) { rc = decompress_buffer(session, session->in_buffer, @@ -1312,7 +1311,6 @@ ssh_packet_socket_callback(const void *data, size_t receivedlen, void *user) goto error; } } -#endif /* WITH_ZLIB */ payloadsize = ssh_buffer_get_len(session->in_buffer); if (session->recv_seq == UINT32_MAX) { /* Overflowing sequence numbers is always fishy */ @@ -1704,7 +1702,6 @@ static int packet_send2(ssh_session session) lenfield_blocksize = 0; } -#ifdef WITH_ZLIB if (crypto != NULL && crypto->do_compress_out && ssh_buffer_get_len(session->out_buffer) > 0) { rc = compress_buffer(session,session->out_buffer); @@ -1713,7 +1710,6 @@ static int packet_send2(ssh_session session) } currentlen = ssh_buffer_get_len(session->out_buffer); } -#endif /* WITH_ZLIB */ compsize = currentlen; /* compressed payload + packet len (4) + padding_size len (1) */ /* totallen - lenfield_blocksize - etm_packet_offset must be equal to 0 (mod blocksize) */ diff --git a/src/wrapper.c b/src/wrapper.c index 5e0a8085..e8f287e9 100644 --- a/src/wrapper.c +++ b/src/wrapper.c @@ -194,9 +194,7 @@ void crypto_free(struct ssh_crypto_struct *crypto) explicit_bzero(crypto->secret_hash, crypto->digest_len); SAFE_FREE(crypto->secret_hash); } -#ifdef WITH_ZLIB compress_cleanup(crypto); -#endif /* WITH_ZLIB */ SAFE_FREE(crypto->encryptIV); SAFE_FREE(crypto->decryptIV); SAFE_FREE(crypto->encryptMAC);