| @@ -47,27 +47,27 @@ | | | @@ -47,27 +47,27 @@ |
47 | * limitations under the License. | | 47 | * limitations under the License. |
48 | */ | | 48 | */ |
49 | | | 49 | |
50 | /** \file | | 50 | /** \file |
51 | */ | | 51 | */ |
52 | #include "config.h" | | 52 | #include "config.h" |
53 | | | 53 | |
54 | #ifdef HAVE_SYS_CDEFS_H | | 54 | #ifdef HAVE_SYS_CDEFS_H |
55 | #include <sys/cdefs.h> | | 55 | #include <sys/cdefs.h> |
56 | #endif | | 56 | #endif |
57 | | | 57 | |
58 | #if defined(__NetBSD__) | | 58 | #if defined(__NetBSD__) |
59 | __COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved."); | | 59 | __COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved."); |
60 | __RCSID("$NetBSD: compress.c,v 1.21 2010/11/15 08:03:39 agc Exp $"); | | 60 | __RCSID("$NetBSD: compress.c,v 1.22 2012/03/04 19:52:02 agc Exp $"); |
61 | #endif | | 61 | #endif |
62 | | | 62 | |
63 | #ifdef HAVE_ZLIB_H | | 63 | #ifdef HAVE_ZLIB_H |
64 | #include <zlib.h> | | 64 | #include <zlib.h> |
65 | #endif | | 65 | #endif |
66 | | | 66 | |
67 | #ifdef HAVE_BZLIB_H | | 67 | #ifdef HAVE_BZLIB_H |
68 | #include <bzlib.h> | | 68 | #include <bzlib.h> |
69 | #endif | | 69 | #endif |
70 | | | 70 | |
71 | #include <string.h> | | 71 | #include <string.h> |
72 | | | 72 | |
73 | #include "packet-parse.h" | | 73 | #include "packet-parse.h" |
| @@ -167,27 +167,28 @@ zlib_compressed_data_reader(pgp_stream_t | | | @@ -167,27 +167,28 @@ zlib_compressed_data_reader(pgp_stream_t |
167 | z->region->last_read : n; | | 167 | z->region->last_read : n; |
168 | } | | 168 | } |
169 | ret = inflate(&z->zstream, Z_SYNC_FLUSH); | | 169 | ret = inflate(&z->zstream, Z_SYNC_FLUSH); |
170 | if (ret == Z_STREAM_END) { | | 170 | if (ret == Z_STREAM_END) { |
171 | if (!z->region->indeterminate && | | 171 | if (!z->region->indeterminate && |
172 | z->region->readc != z->region->length) { | | 172 | z->region->readc != z->region->length) { |
173 | PGP_ERROR(cbinfo->errors, | | 173 | PGP_ERROR(cbinfo->errors, |
174 | PGP_E_P_DECOMPRESSION_ERROR, | | 174 | PGP_E_P_DECOMPRESSION_ERROR, |
175 | "Compressed stream ended before packet end."); | | 175 | "Compressed stream ended before packet end."); |
176 | } | | 176 | } |
177 | } else if (ret != Z_OK) { | | 177 | } else if (ret != Z_OK) { |
178 | (void) fprintf(stderr, "ret=%d\n", ret); | | 178 | (void) fprintf(stderr, "ret=%d\n", ret); |
179 | PGP_ERROR(cbinfo->errors, | | 179 | PGP_ERROR(cbinfo->errors, |
180 | PGP_E_P_DECOMPRESSION_ERROR, z->zstream.msg); | | 180 | PGP_E_P_DECOMPRESSION_ERROR, "%s", |
| | | 181 | z->zstream.msg); |
181 | } | | 182 | } |
182 | z->inflate_ret = ret; | | 183 | z->inflate_ret = ret; |
183 | } | | 184 | } |
184 | if (z->zstream.next_out <= &z->out[z->offset]) { | | 185 | if (z->zstream.next_out <= &z->out[z->offset]) { |
185 | (void) fprintf(stderr, "Out of memory in buffer\n"); | | 186 | (void) fprintf(stderr, "Out of memory in buffer\n"); |
186 | return 0; | | 187 | return 0; |
187 | } | | 188 | } |
188 | len = (size_t)(z->zstream.next_out - &z->out[z->offset]); | | 189 | len = (size_t)(z->zstream.next_out - &z->out[z->offset]); |
189 | if (len > length) { | | 190 | if (len > length) { |
190 | len = length; | | 191 | len = length; |
191 | } | | 192 | } |
192 | (void) memcpy(&cdest[cc], &z->out[z->offset], len); | | 193 | (void) memcpy(&cdest[cc], &z->out[z->offset], len); |
193 | z->offset += len; | | 194 | z->offset += len; |