pgsql: Fix corner case with PGP decompression in pgcrypto

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix corner case with PGP decompression in pgcrypto
Date: 2020-07-22 05:54:41
Message-ID: E1jy7iD-0007JV-UM@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix corner case with PGP decompression in pgcrypto

A compressed stream may end with an empty packet, and PGP decompression
finished before reading this empty packet in the remaining stream. This
caused a failure in pgcrypto, handling this case as corrupted data.
This commit makes sure to consume such extra data, avoiding a failure
when decompression the entire stream. This corner case was reproducible
with a data length of 16kB, and existed since its introduction in
e94dd6a. A cheap regression test is added to cover this case.

Thanks to Jeff Janes for the extra investigation.

Reported-by: Frank Gagnepain
Author: Kyotaro Horiguchi, Michael Paquier
Discussion: https://postgr.es/m/16476-692ef7b84e5fb893@postgresql.org
Backpatch-through: 9.5

Branch
------
REL9_5_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/dbf17ca1bfab1aec5783a1768d784875fb73a603

Modified Files
--------------
contrib/pgcrypto/expected/pgp-compression.out | 30 +++++++++++++++++++++++++++
contrib/pgcrypto/pgp-compress.c | 22 ++++++++++----------
contrib/pgcrypto/sql/pgp-compression.sql | 21 +++++++++++++++++++
3 files changed, 62 insertions(+), 11 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2020-07-22 23:19:55 pgsql: Support infinity and -infinity in the numeric data type.
Previous Message Thomas Munro 2020-07-22 04:52:41 pgsql: Fix conversion table generator scripts.