From 68ea0f43533096d5c46bad4aee6e5d5864307f4a Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 12 Dec 1997 12:03:58 +0000 Subject: added option file handling --- g10/compress.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'g10/compress.c') diff --git a/g10/compress.c b/g10/compress.c index d0e2bc539..2b10c983b 100644 --- a/g10/compress.c +++ b/g10/compress.c @@ -106,7 +106,13 @@ init_uncompress( compress_filter_context_t *zfx, z_stream *zs ) int level; - if( (rc = inflateInit( zs )) != Z_OK ) { + /**************** + * PGP uses a windowsize of 13 bits. Using a negative value for + * it forces zlib not to expect a zlib header. This is a + * undocumented feature, Peter Gutmann told me about. + */ + if( (rc = zfx->pgpmode? inflateInit2( zs, -13) + : inflateInit( zs )) != Z_OK ) { log_fatal("zlib problem: %s\n", zs->msg? zs->msg : rc == Z_MEM_ERROR ? "out of core" : rc == Z_VERSION_ERROR ? "invalid lib version" : @@ -265,7 +271,9 @@ handle_compressed( PKT_compressed *cd ) compress_filter_context_t cfx; memset( &cfx, 0, sizeof cfx ); - if( cd->algorithm != 2 ) + if( cd->algorithm == 1 ) + cfx.pgpmode = 1; + else if( cd->algorithm != 2 ) return G10ERR_COMPR_ALGO; iobuf_push_filter( cd->buf, compress_filter, &cfx ); -- cgit v1.2.3