summaryrefslogtreecommitdiff
path: root/compress.c
diff options
context:
space:
mode:
Diffstat (limited to 'compress.c')
-rw-r--r--compress.c40
1 files changed, 9 insertions, 31 deletions
diff --git a/compress.c b/compress.c
index cf15c6670..ee5cdccb5 100644
--- a/compress.c
+++ b/compress.c
@@ -14,7 +14,7 @@
14 */ 14 */
15 15
16#include "includes.h" 16#include "includes.h"
17RCSID("$Id: compress.c,v 1.4 2000/03/17 12:40:16 damien Exp $"); 17RCSID("$Id: compress.c,v 1.5 2000/04/01 01:09:24 damien Exp $");
18 18
19#include "ssh.h" 19#include "ssh.h"
20#include "buffer.h" 20#include "buffer.h"
@@ -90,23 +90,13 @@ buffer_compress(Buffer * input_buffer, Buffer * output_buffer)
90 case Z_OK: 90 case Z_OK:
91 /* Append compressed data to output_buffer. */ 91 /* Append compressed data to output_buffer. */
92 buffer_append(output_buffer, buf, 92 buffer_append(output_buffer, buf,
93 sizeof(buf) - outgoing_stream.avail_out); 93 sizeof(buf) - outgoing_stream.avail_out);
94 break; 94 break;
95 case Z_STREAM_END:
96 fatal("buffer_compress: deflate returned Z_STREAM_END");
97 /* NOTREACHED */
98 case Z_STREAM_ERROR:
99 fatal("buffer_compress: deflate returned Z_STREAM_ERROR");
100 /* NOTREACHED */
101 case Z_BUF_ERROR:
102 fatal("buffer_compress: deflate returned Z_BUF_ERROR");
103 /* NOTREACHED */
104 default: 95 default:
105 fatal("buffer_compress: deflate returned %d", status); 96 fatal("buffer_compress: deflate returned %d", status);
106 /* NOTREACHED */ 97 /* NOTREACHED */
107 } 98 }
108 } 99 } while (outgoing_stream.avail_out == 0);
109 while (outgoing_stream.avail_out == 0);
110} 100}
111 101
112/* 102/*
@@ -127,27 +117,17 @@ buffer_uncompress(Buffer * input_buffer, Buffer * output_buffer)
127 incoming_stream.next_in = (unsigned char *) buffer_ptr(input_buffer); 117 incoming_stream.next_in = (unsigned char *) buffer_ptr(input_buffer);
128 incoming_stream.avail_in = buffer_len(input_buffer); 118 incoming_stream.avail_in = buffer_len(input_buffer);
129 119
130 incoming_stream.next_out = (unsigned char *) buf;
131 incoming_stream.avail_out = sizeof(buf);
132
133 for (;;) { 120 for (;;) {
121 /* Set up fixed-size output buffer. */
122 incoming_stream.next_out = (unsigned char *) buf;
123 incoming_stream.avail_out = sizeof(buf);
124
134 status = inflate(&incoming_stream, Z_PARTIAL_FLUSH); 125 status = inflate(&incoming_stream, Z_PARTIAL_FLUSH);
135 switch (status) { 126 switch (status) {
136 case Z_OK: 127 case Z_OK:
137 buffer_append(output_buffer, buf, 128 buffer_append(output_buffer, buf,
138 sizeof(buf) - incoming_stream.avail_out); 129 sizeof(buf) - incoming_stream.avail_out);
139 incoming_stream.next_out = (unsigned char *) buf;
140 incoming_stream.avail_out = sizeof(buf);
141 break; 130 break;
142 case Z_STREAM_END:
143 fatal("buffer_uncompress: inflate returned Z_STREAM_END");
144 /* NOTREACHED */
145 case Z_DATA_ERROR:
146 fatal("buffer_uncompress: inflate returned Z_DATA_ERROR");
147 /* NOTREACHED */
148 case Z_STREAM_ERROR:
149 fatal("buffer_uncompress: inflate returned Z_STREAM_ERROR");
150 /* NOTREACHED */
151 case Z_BUF_ERROR: 131 case Z_BUF_ERROR:
152 /* 132 /*
153 * Comments in zlib.h say that we should keep calling 133 * Comments in zlib.h say that we should keep calling
@@ -155,11 +135,9 @@ buffer_uncompress(Buffer * input_buffer, Buffer * output_buffer)
155 * be the error that we get. 135 * be the error that we get.
156 */ 136 */
157 return; 137 return;
158 case Z_MEM_ERROR:
159 fatal("buffer_uncompress: inflate returned Z_MEM_ERROR");
160 /* NOTREACHED */
161 default: 138 default:
162 fatal("buffer_uncompress: inflate returned %d", status); 139 fatal("buffer_uncompress: inflate returned %d", status);
140 /* NOTREACHED */
163 } 141 }
164 } 142 }
165} 143}