X-Git-Url: http://andersk.mit.edu/gitweb/openssh.git/blobdiff_plain/91885a4d5370e317c337cdc779bfdd654d921a1a..319d6b4106939b262ee7a053e1a5d72e118aaee2:/compress.c diff --git a/compress.c b/compress.c index dec96ba5..8aba84ef 100644 --- a/compress.c +++ b/compress.c @@ -1,3 +1,4 @@ +/* $OpenBSD: compress.c,v 1.23 2006/03/25 13:17:01 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -12,7 +13,6 @@ */ #include "includes.h" -RCSID("$OpenBSD: compress.c,v 1.17 2001/12/29 21:56:01 stevesk Exp $"); #include "log.h" #include "buffer.h" @@ -23,6 +23,8 @@ z_stream incoming_stream; z_stream outgoing_stream; static int compress_init_send_called = 0; static int compress_init_recv_called = 0; +static int inflate_failed = 0; +static int deflate_failed = 0; /* * Initializes compression; level is compression level from 1 to 9 @@ -54,17 +56,19 @@ buffer_compress_init_recv(void) void buffer_compress_uninit(void) { - debug("compress outgoing: raw data %lu, compressed %lu, factor %.2f", - outgoing_stream.total_in, outgoing_stream.total_out, + debug("compress outgoing: raw data %llu, compressed %llu, factor %.2f", + (unsigned long long)outgoing_stream.total_in, + (unsigned long long)outgoing_stream.total_out, outgoing_stream.total_in == 0 ? 0.0 : (double) outgoing_stream.total_out / outgoing_stream.total_in); - debug("compress incoming: raw data %lu, compressed %lu, factor %.2f", - incoming_stream.total_out, incoming_stream.total_in, + debug("compress incoming: raw data %llu, compressed %llu, factor %.2f", + (unsigned long long)incoming_stream.total_out, + (unsigned long long)incoming_stream.total_in, incoming_stream.total_out == 0 ? 0.0 : (double) incoming_stream.total_in / incoming_stream.total_out); - if (compress_init_recv_called == 1) + if (compress_init_recv_called == 1 && inflate_failed == 0) inflateEnd(&incoming_stream); - if (compress_init_send_called == 1) + if (compress_init_send_called == 1 && deflate_failed == 0) deflateEnd(&outgoing_stream); } @@ -106,6 +110,7 @@ buffer_compress(Buffer * input_buffer, Buffer * output_buffer) sizeof(buf) - outgoing_stream.avail_out); break; default: + deflate_failed = 1; fatal("buffer_compress: deflate returned %d", status); /* NOTREACHED */ } @@ -149,6 +154,7 @@ buffer_uncompress(Buffer * input_buffer, Buffer * output_buffer) */ return; default: + inflate_failed = 1; fatal("buffer_uncompress: inflate returned %d", status); /* NOTREACHED */ }