[PATCH 3/3] Fix the "gpg: [don't know]: invalid packet (ctb=14)" bug
Florian Weimer
fweimer at bfk.de
Mon Sep 25 11:58:21 CEST 2006
In some cases, zlib does not consume all bytes from the supplied
buffer. The code did not handle this situation at all, essentially
dropping these bytes. The fix uses the new iobuf_unread function
to stuff the unread bytes back into the IOBUF where they came from.
---
g10/compress.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/g10/compress.c b/g10/compress.c
index 0cee5ae..9c0a4a4 100644
--- a/g10/compress.c
+++ b/g10/compress.c
@@ -210,6 +210,15 @@ #endif
log_fatal("zlib inflate problem: rc=%d\n", zrc );
}
} while( zs->avail_out && zrc != Z_STREAM_END && zrc != Z_BUF_ERROR );
+
+ if( zrc == Z_STREAM_END && zs->avail_in ) {
+ iobuf_unread(a, zs->next_in, zs->avail_in);
+ if( DBG_FILTER )
+ log_debug("inflate: left %u bytes, unget buffer now has %u\n",
+ (unsigned)zs->avail_in, a->unget.len - a->unget.start);
+ zs->avail_in = 0;
+ }
+
*ret_len = zfx->outbufsize - zs->avail_out;
if( DBG_FILTER )
log_debug("do_uncompress: returning %u bytes\n", (unsigned)*ret_len );
--
1.4.2.1
More information about the Gnupg-devel
mailing list