aboutsummaryrefslogtreecommitdiff
path: root/contrib/pgcrypto/pgp-compress.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/pgcrypto/pgp-compress.c')
-rw-r--r--contrib/pgcrypto/pgp-compress.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/contrib/pgcrypto/pgp-compress.c b/contrib/pgcrypto/pgp-compress.c
index e153940ba8c..88b3f478535 100644
--- a/contrib/pgcrypto/pgp-compress.c
+++ b/contrib/pgcrypto/pgp-compress.c
@@ -287,7 +287,28 @@ restart:
dec->buf_data = dec->buf_len - dec->stream.avail_out;
if (res == Z_STREAM_END)
+ {
+ uint8 *tmp;
+
+ /*
+ * A stream must be terminated by a normal packet. If the last stream
+ * packet in the source stream is a full packet, a normal empty packet
+ * must follow. Since the underlying packet reader doesn't know that
+ * the compressed stream has been ended, we need to to consume the
+ * terminating packet here. This read does not harm even if the
+ * stream has already ended.
+ */
+ res = pullf_read(src, 1, &tmp);
+
+ if (res < 0)
+ return res;
+ else if (res > 0)
+ {
+ px_debug("decompress_read: extra bytes after end of stream");
+ return PXE_PGP_CORRUPT_DATA;
+ }
dec->eof = 1;
+ }
goto restart;
}