Re: BUG #16476: pgp_sym_encrypt_bytea with compress-level=6 : Wrong key or corrupt data

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: jeff(dot)janes(at)gmail(dot)com
Cc: frank(dot)gagnepain(at)intm(dot)fr, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16476: pgp_sym_encrypt_bytea with compress-level=6 : Wrong key or corrupt data
Date: 2020-06-11 11:58:31
Message-ID: 20200611.205831.1200962108435398529.horikyota.ntt@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

At Wed, 3 Jun 2020 08:35:02 -0400, Jeff Janes <jeff(dot)janes(at)gmail(dot)com> wrote in
> I can reproduce this at any compression level if the data is random (not
> compressible) and exactly 16365 bytes long. If the data is compressible,
> then you need a longer length of message to reproduce it and it depends on
> the random content and compression level.
>
> I'm attaching the reproducer as a Perl script. I have not investigated the
> C code of pgcrypto itself.

Thanks for the reproducer.

Compressed stream must end with a normal packet. If a stream ends with
a complete stream packet, deflator adds a zero-length normal packet at
the end. decompress_read forgets to read such a terminating packet
when EOF comes at just at the end of the last stream packet. An extra
call to pullf_read at EOF correctly consumes such an extra packet.
The extra call doesn't harm if a stream ends with partial normal
packet.

The reproducer becomes not to fail with the attached patch.

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

Attachment Content-Type Size
0001-Make-sure-to-consume-stream-terminating-packet.patch text/x-patch 1.2 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Kyle Kingsbury 2020-06-11 12:39:13 Re: Potential G2-item cycles under serializable isolation
Previous Message Tom Lane 2020-06-11 11:16:48 Re: pg_stat_statements: duplicated external query texts with MSY2