mirror of git://anongit.mindrot.org/openssh.git
- markus@cvs.openbsd.org 2001/04/05 10:39:03
[compress.c compress.h packet.c] reset compress state per direction when rekeying.
This commit is contained in:
parent
4f3ae4c550
commit
fb50cdfdb8
|
@ -4,6 +4,9 @@
|
|||
- markus@cvs.openbsd.org 2001/04/05 10:00:06
|
||||
[compat.c]
|
||||
2.3.x does old GEX, too; report jakob@
|
||||
- markus@cvs.openbsd.org 2001/04/05 10:39:03
|
||||
[compress.c compress.h packet.c]
|
||||
reset compress state per direction when rekeying.
|
||||
|
||||
20010405
|
||||
- OpenBSD CVS Sync
|
||||
|
@ -4876,4 +4879,4 @@
|
|||
- Wrote replacements for strlcpy and mkdtemp
|
||||
- Released 1.0pre1
|
||||
|
||||
$Id: ChangeLog,v 1.1064 2001/04/05 23:19:21 mouring Exp $
|
||||
$Id: ChangeLog,v 1.1065 2001/04/05 23:20:46 mouring Exp $
|
||||
|
|
24
compress.c
24
compress.c
|
@ -12,7 +12,7 @@
|
|||
*/
|
||||
|
||||
#include "includes.h"
|
||||
RCSID("$OpenBSD: compress.c,v 1.13 2001/02/08 19:30:51 itojun Exp $");
|
||||
RCSID("$OpenBSD: compress.c,v 1.14 2001/04/05 10:39:01 markus Exp $");
|
||||
|
||||
#include "log.h"
|
||||
#include "buffer.h"
|
||||
|
@ -21,6 +21,8 @@ RCSID("$OpenBSD: compress.c,v 1.13 2001/02/08 19:30:51 itojun Exp $");
|
|||
|
||||
static z_stream incoming_stream;
|
||||
static z_stream outgoing_stream;
|
||||
static int compress_init_send_called = 0;
|
||||
static int compress_init_recv_called = 0;
|
||||
|
||||
/*
|
||||
* Initializes compression; level is compression level from 1 to 9
|
||||
|
@ -28,14 +30,24 @@ static z_stream outgoing_stream;
|
|||
*/
|
||||
|
||||
void
|
||||
buffer_compress_init(int level)
|
||||
buffer_compress_init_send(int level)
|
||||
{
|
||||
if (compress_init_send_called == 1)
|
||||
deflateEnd(&incoming_stream);
|
||||
compress_init_send_called = 1;
|
||||
debug("Enabling compression at level %d.", level);
|
||||
if (level < 1 || level > 9)
|
||||
fatal("Bad compression level %d.", level);
|
||||
inflateInit(&incoming_stream);
|
||||
deflateInit(&outgoing_stream, level);
|
||||
}
|
||||
void
|
||||
buffer_compress_init_recv(void)
|
||||
{
|
||||
if (compress_init_recv_called == 1)
|
||||
inflateEnd(&incoming_stream);
|
||||
compress_init_recv_called = 1;
|
||||
inflateInit(&incoming_stream);
|
||||
}
|
||||
|
||||
/* Frees any data structures allocated for compression. */
|
||||
|
||||
|
@ -50,8 +62,10 @@ buffer_compress_uninit(void)
|
|||
incoming_stream.total_out, incoming_stream.total_in,
|
||||
incoming_stream.total_out == 0 ? 0.0 :
|
||||
(double) incoming_stream.total_in / incoming_stream.total_out);
|
||||
inflateEnd(&incoming_stream);
|
||||
deflateEnd(&outgoing_stream);
|
||||
if (compress_init_recv_called == 1)
|
||||
inflateEnd(&incoming_stream);
|
||||
if (compress_init_send_called == 1)
|
||||
deflateEnd(&outgoing_stream);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
* called by a name other than "ssh" or "Secure Shell".
|
||||
*/
|
||||
|
||||
/* RCSID("$OpenBSD: compress.h,v 1.7 2000/12/20 19:37:22 markus Exp $"); */
|
||||
/* RCSID("$OpenBSD: compress.h,v 1.8 2001/04/05 10:39:02 markus Exp $"); */
|
||||
|
||||
#ifndef COMPRESS_H
|
||||
#define COMPRESS_H
|
||||
|
@ -20,7 +20,8 @@
|
|||
* Initializes compression; level is compression level from 1 to 9 (as in
|
||||
* gzip).
|
||||
*/
|
||||
void buffer_compress_init(int level);
|
||||
void buffer_compress_init_send(int level);
|
||||
void buffer_compress_init_recv(void);
|
||||
|
||||
/* Frees any data structures allocated by buffer_compress_init. */
|
||||
void buffer_compress_uninit(void);
|
||||
|
|
29
packet.c
29
packet.c
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include "includes.h"
|
||||
RCSID("$OpenBSD: packet.c,v 1.59 2001/04/04 23:09:18 markus Exp $");
|
||||
RCSID("$OpenBSD: packet.c,v 1.60 2001/04/05 10:39:03 markus Exp $");
|
||||
|
||||
#include "xmalloc.h"
|
||||
#include "buffer.h"
|
||||
|
@ -104,6 +104,7 @@ static Buffer incoming_packet;
|
|||
|
||||
/* Scratch buffer for packet compression/decompression. */
|
||||
static Buffer compression_buffer;
|
||||
static int compression_buffer_ready = 0;
|
||||
|
||||
/* Flag indicating whether packet compression/decompression is enabled. */
|
||||
static int packet_compression = 0;
|
||||
|
@ -249,7 +250,7 @@ packet_close()
|
|||
buffer_free(&output);
|
||||
buffer_free(&outgoing_packet);
|
||||
buffer_free(&incoming_packet);
|
||||
if (packet_compression) {
|
||||
if (compression_buffer_ready) {
|
||||
buffer_free(&compression_buffer);
|
||||
buffer_compress_uninit();
|
||||
}
|
||||
|
@ -277,15 +278,24 @@ packet_get_protocol_flags()
|
|||
* Level is compression level 1 (fastest) - 9 (slow, best) as in gzip.
|
||||
*/
|
||||
|
||||
/*** XXXXX todo: kex means re-init */
|
||||
void
|
||||
packet_init_compression()
|
||||
{
|
||||
if (compression_buffer_ready == 1)
|
||||
return;
|
||||
compression_buffer_ready = 1;
|
||||
buffer_init(&compression_buffer);
|
||||
}
|
||||
|
||||
void
|
||||
packet_start_compression(int level)
|
||||
{
|
||||
if (packet_compression)
|
||||
if (packet_compression && !use_ssh2_packet_format)
|
||||
fatal("Compression already enabled.");
|
||||
packet_compression = 1;
|
||||
buffer_init(&compression_buffer);
|
||||
buffer_compress_init(level);
|
||||
packet_init_compression();
|
||||
buffer_compress_init_send(level);
|
||||
buffer_compress_init_recv();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -542,9 +552,12 @@ set_newkeys(int mode)
|
|||
memset(enc->iv, 0, enc->cipher->block_size);
|
||||
memset(enc->key, 0, enc->cipher->key_len);
|
||||
if (comp->type != 0 && comp->enabled == 0) {
|
||||
packet_init_compression();
|
||||
if (mode == MODE_OUT)
|
||||
buffer_compress_init_send(6);
|
||||
else
|
||||
buffer_compress_init_recv();
|
||||
comp->enabled = 1;
|
||||
if (! packet_compression)
|
||||
packet_start_compression(6);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue