pgcrypto: Fix check for buffer size

Daniel Gustafsson <dgustafsson@postgresql.org>

Commit: 5d726c72cd0f6b13842896058151bac5f68b4100
Author: Daniel Gustafsson <dgustafsson@postgresql.org>
Date: 2024-01-30T10:15:46Z
Releases: 16.2
pgcrypto: Fix check for buffer size

The code copying the PGP block into the temp buffer failed to
account for the extra 2 bytes in the buffer which are needed
for the prefix. If the block was oversized, subsequent checks
of the prefix would have exceeded the buffer size.  Since the
block sizes are hardcoded in the list of supported ciphers it
can be verified that there is no live bug here. Backpatch all
the way for consistency though, as this bug is old.

Author: Mikhail Gribkov <youzhick@gmail.com>
Discussion: https://postgr.es/m/CAMEv5_uWvcMCMdRFDsJLz2Q8g16HEa9xWyfrkr+FYMMFJhawOw@mail.gmail.com
Backpatch-through: v12

Files

PathChange+/−
contrib/pgcrypto/pgp-decrypt.c modified +2 −1

Discussion