diff options
author | dtucker@openbsd.org <dtucker@openbsd.org> | 2020-01-23 10:24:29 +0000 |
---|---|---|
committer | Darren Tucker <dtucker@dtucker.net> | 2020-01-23 21:53:54 +1100 |
commit | 7f8e66fea8c4e2a910df9067cb7638999b7764d5 (patch) | |
tree | 88c1a4a73a03cfa993fee0c1f23b6327ef1351a1 /packet.c | |
parent | 69ac4e33023b379e9a8e9b4b6aeeffa6d1fcf6fa (diff) |
upstream: Make zlib optional. This adds a "ZLIB" build time option
that allows building without zlib compression and associated options. With
feedback from markus@, ok djm@
OpenBSD-Commit-ID: 44c6e1133a90fd15a3aa865bdedc53bab28b7910
Diffstat (limited to 'packet.c')
-rw-r--r-- | packet.c | 38 |
1 files changed, 36 insertions, 2 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: packet.c,v 1.287 2019/12/16 13:58:53 tobhe Exp $ */ | 1 | /* $OpenBSD: packet.c,v 1.288 2020/01/23 10:24:29 dtucker Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -76,7 +76,9 @@ | |||
76 | # endif | 76 | # endif |
77 | #endif | 77 | #endif |
78 | 78 | ||
79 | #ifdef WITH_ZLIB | ||
79 | #include <zlib.h> | 80 | #include <zlib.h> |
81 | #endif | ||
80 | 82 | ||
81 | #include "xmalloc.h" | 83 | #include "xmalloc.h" |
82 | #include "compat.h" | 84 | #include "compat.h" |
@@ -150,9 +152,11 @@ struct session_state { | |||
150 | /* Scratch buffer for packet compression/decompression. */ | 152 | /* Scratch buffer for packet compression/decompression. */ |
151 | struct sshbuf *compression_buffer; | 153 | struct sshbuf *compression_buffer; |
152 | 154 | ||
155 | #ifdef WITH_ZLIB | ||
153 | /* Incoming/outgoing compression dictionaries */ | 156 | /* Incoming/outgoing compression dictionaries */ |
154 | z_stream compression_in_stream; | 157 | z_stream compression_in_stream; |
155 | z_stream compression_out_stream; | 158 | z_stream compression_out_stream; |
159 | #endif | ||
156 | int compression_in_started; | 160 | int compression_in_started; |
157 | int compression_out_started; | 161 | int compression_out_started; |
158 | int compression_in_failures; | 162 | int compression_in_failures; |
@@ -609,7 +613,8 @@ ssh_packet_close_internal(struct ssh *ssh, int do_close) | |||
609 | state->newkeys[mode] = NULL; | 613 | state->newkeys[mode] = NULL; |
610 | ssh_clear_newkeys(ssh, mode); /* next keys */ | 614 | ssh_clear_newkeys(ssh, mode); /* next keys */ |
611 | } | 615 | } |
612 | /* compression state is in shared mem, so we can only release it once */ | 616 | #ifdef WITH_ZLIB |
617 | /* comression state is in shared mem, so we can only release it once */ | ||
613 | if (do_close && state->compression_buffer) { | 618 | if (do_close && state->compression_buffer) { |
614 | sshbuf_free(state->compression_buffer); | 619 | sshbuf_free(state->compression_buffer); |
615 | if (state->compression_out_started) { | 620 | if (state->compression_out_started) { |
@@ -635,6 +640,7 @@ ssh_packet_close_internal(struct ssh *ssh, int do_close) | |||
635 | inflateEnd(stream); | 640 | inflateEnd(stream); |
636 | } | 641 | } |
637 | } | 642 | } |
643 | #endif /* WITH_ZLIB */ | ||
638 | cipher_free(state->send_context); | 644 | cipher_free(state->send_context); |
639 | cipher_free(state->receive_context); | 645 | cipher_free(state->receive_context); |
640 | state->send_context = state->receive_context = NULL; | 646 | state->send_context = state->receive_context = NULL; |
@@ -690,6 +696,7 @@ ssh_packet_init_compression(struct ssh *ssh) | |||
690 | return 0; | 696 | return 0; |
691 | } | 697 | } |
692 | 698 | ||
699 | #ifdef WITH_ZLIB | ||
693 | static int | 700 | static int |
694 | start_compression_out(struct ssh *ssh, int level) | 701 | start_compression_out(struct ssh *ssh, int level) |
695 | { | 702 | { |
@@ -821,6 +828,33 @@ uncompress_buffer(struct ssh *ssh, struct sshbuf *in, struct sshbuf *out) | |||
821 | /* NOTREACHED */ | 828 | /* NOTREACHED */ |
822 | } | 829 | } |
823 | 830 | ||
831 | #else /* WITH_ZLIB */ | ||
832 | |||
833 | static int | ||
834 | start_compression_out(struct ssh *ssh, int level) | ||
835 | { | ||
836 | return SSH_ERR_INTERNAL_ERROR; | ||
837 | } | ||
838 | |||
839 | static int | ||
840 | start_compression_in(struct ssh *ssh) | ||
841 | { | ||
842 | return SSH_ERR_INTERNAL_ERROR; | ||
843 | } | ||
844 | |||
845 | static int | ||
846 | compress_buffer(struct ssh *ssh, struct sshbuf *in, struct sshbuf *out) | ||
847 | { | ||
848 | return SSH_ERR_INTERNAL_ERROR; | ||
849 | } | ||
850 | |||
851 | static int | ||
852 | uncompress_buffer(struct ssh *ssh, struct sshbuf *in, struct sshbuf *out) | ||
853 | { | ||
854 | return SSH_ERR_INTERNAL_ERROR; | ||
855 | } | ||
856 | #endif /* WITH_ZLIB */ | ||
857 | |||
824 | void | 858 | void |
825 | ssh_clear_newkeys(struct ssh *ssh, int mode) | 859 | ssh_clear_newkeys(struct ssh *ssh, int mode) |
826 | { | 860 | { |