From: markus Date: Tue, 28 Mar 2000 20:25:14 +0000 (+0000) Subject: cleanup, less code X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=9e0b12caebc9ebd99b936ff33e7cbcefd89c56e2;p=openbsd cleanup, less code --- diff --git a/usr.bin/ssh/compress.c b/usr.bin/ssh/compress.c index 03e50817396..d04b6eb4804 100644 --- a/usr.bin/ssh/compress.c +++ b/usr.bin/ssh/compress.c @@ -14,7 +14,7 @@ */ #include "includes.h" -RCSID("$Id: compress.c,v 1.5 2000/03/16 20:56:14 markus Exp $"); +RCSID("$Id: compress.c,v 1.6 2000/03/28 20:25:14 markus Exp $"); #include "ssh.h" #include "buffer.h" @@ -90,23 +90,13 @@ buffer_compress(Buffer * input_buffer, Buffer * output_buffer) case Z_OK: /* Append compressed data to output_buffer. */ buffer_append(output_buffer, buf, - sizeof(buf) - outgoing_stream.avail_out); + sizeof(buf) - outgoing_stream.avail_out); break; - case Z_STREAM_END: - fatal("buffer_compress: deflate returned Z_STREAM_END"); - /* NOTREACHED */ - case Z_STREAM_ERROR: - fatal("buffer_compress: deflate returned Z_STREAM_ERROR"); - /* NOTREACHED */ - case Z_BUF_ERROR: - fatal("buffer_compress: deflate returned Z_BUF_ERROR"); - /* NOTREACHED */ default: fatal("buffer_compress: deflate returned %d", status); /* NOTREACHED */ } - } - while (outgoing_stream.avail_out == 0); + } while (outgoing_stream.avail_out == 0); } /* @@ -127,27 +117,17 @@ buffer_uncompress(Buffer * input_buffer, Buffer * output_buffer) incoming_stream.next_in = (unsigned char *) buffer_ptr(input_buffer); incoming_stream.avail_in = buffer_len(input_buffer); - incoming_stream.next_out = (unsigned char *) buf; - incoming_stream.avail_out = sizeof(buf); - for (;;) { + /* Set up fixed-size output buffer. */ + incoming_stream.next_out = (unsigned char *) buf; + incoming_stream.avail_out = sizeof(buf); + status = inflate(&incoming_stream, Z_PARTIAL_FLUSH); switch (status) { case Z_OK: buffer_append(output_buffer, buf, - sizeof(buf) - incoming_stream.avail_out); - incoming_stream.next_out = (unsigned char *) buf; - incoming_stream.avail_out = sizeof(buf); + sizeof(buf) - incoming_stream.avail_out); break; - case Z_STREAM_END: - fatal("buffer_uncompress: inflate returned Z_STREAM_END"); - /* NOTREACHED */ - case Z_DATA_ERROR: - fatal("buffer_uncompress: inflate returned Z_DATA_ERROR"); - /* NOTREACHED */ - case Z_STREAM_ERROR: - fatal("buffer_uncompress: inflate returned Z_STREAM_ERROR"); - /* NOTREACHED */ case Z_BUF_ERROR: /* * Comments in zlib.h say that we should keep calling @@ -155,11 +135,9 @@ buffer_uncompress(Buffer * input_buffer, Buffer * output_buffer) * be the error that we get. */ return; - case Z_MEM_ERROR: - fatal("buffer_uncompress: inflate returned Z_MEM_ERROR"); - /* NOTREACHED */ default: fatal("buffer_uncompress: inflate returned %d", status); + /* NOTREACHED */ } } }