diff options
Diffstat (limited to 'packet.c')
-rw-r--r-- | packet.c | 29 |
1 files changed, 21 insertions, 8 deletions
@@ -37,7 +37,7 @@ | |||
37 | */ | 37 | */ |
38 | 38 | ||
39 | #include "includes.h" | 39 | #include "includes.h" |
40 | RCSID("$OpenBSD: packet.c,v 1.59 2001/04/04 23:09:18 markus Exp $"); | 40 | RCSID("$OpenBSD: packet.c,v 1.60 2001/04/05 10:39:03 markus Exp $"); |
41 | 41 | ||
42 | #include "xmalloc.h" | 42 | #include "xmalloc.h" |
43 | #include "buffer.h" | 43 | #include "buffer.h" |
@@ -104,6 +104,7 @@ static Buffer incoming_packet; | |||
104 | 104 | ||
105 | /* Scratch buffer for packet compression/decompression. */ | 105 | /* Scratch buffer for packet compression/decompression. */ |
106 | static Buffer compression_buffer; | 106 | static Buffer compression_buffer; |
107 | static int compression_buffer_ready = 0; | ||
107 | 108 | ||
108 | /* Flag indicating whether packet compression/decompression is enabled. */ | 109 | /* Flag indicating whether packet compression/decompression is enabled. */ |
109 | static int packet_compression = 0; | 110 | static int packet_compression = 0; |
@@ -249,7 +250,7 @@ packet_close() | |||
249 | buffer_free(&output); | 250 | buffer_free(&output); |
250 | buffer_free(&outgoing_packet); | 251 | buffer_free(&outgoing_packet); |
251 | buffer_free(&incoming_packet); | 252 | buffer_free(&incoming_packet); |
252 | if (packet_compression) { | 253 | if (compression_buffer_ready) { |
253 | buffer_free(&compression_buffer); | 254 | buffer_free(&compression_buffer); |
254 | buffer_compress_uninit(); | 255 | buffer_compress_uninit(); |
255 | } | 256 | } |
@@ -277,15 +278,24 @@ packet_get_protocol_flags() | |||
277 | * Level is compression level 1 (fastest) - 9 (slow, best) as in gzip. | 278 | * Level is compression level 1 (fastest) - 9 (slow, best) as in gzip. |
278 | */ | 279 | */ |
279 | 280 | ||
280 | /*** XXXXX todo: kex means re-init */ | 281 | void |
282 | packet_init_compression() | ||
283 | { | ||
284 | if (compression_buffer_ready == 1) | ||
285 | return; | ||
286 | compression_buffer_ready = 1; | ||
287 | buffer_init(&compression_buffer); | ||
288 | } | ||
289 | |||
281 | void | 290 | void |
282 | packet_start_compression(int level) | 291 | packet_start_compression(int level) |
283 | { | 292 | { |
284 | if (packet_compression) | 293 | if (packet_compression && !use_ssh2_packet_format) |
285 | fatal("Compression already enabled."); | 294 | fatal("Compression already enabled."); |
286 | packet_compression = 1; | 295 | packet_compression = 1; |
287 | buffer_init(&compression_buffer); | 296 | packet_init_compression(); |
288 | buffer_compress_init(level); | 297 | buffer_compress_init_send(level); |
298 | buffer_compress_init_recv(); | ||
289 | } | 299 | } |
290 | 300 | ||
291 | /* | 301 | /* |
@@ -542,9 +552,12 @@ set_newkeys(int mode) | |||
542 | memset(enc->iv, 0, enc->cipher->block_size); | 552 | memset(enc->iv, 0, enc->cipher->block_size); |
543 | memset(enc->key, 0, enc->cipher->key_len); | 553 | memset(enc->key, 0, enc->cipher->key_len); |
544 | if (comp->type != 0 && comp->enabled == 0) { | 554 | if (comp->type != 0 && comp->enabled == 0) { |
555 | packet_init_compression(); | ||
556 | if (mode == MODE_OUT) | ||
557 | buffer_compress_init_send(6); | ||
558 | else | ||
559 | buffer_compress_init_recv(); | ||
545 | comp->enabled = 1; | 560 | comp->enabled = 1; |
546 | if (! packet_compression) | ||
547 | packet_start_compression(6); | ||
548 | } | 561 | } |
549 | } | 562 | } |
550 | 563 | ||