aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gustafsson <dgustafsson@postgresql.org>2024-01-30 11:15:46 +0100
committerDaniel Gustafsson <dgustafsson@postgresql.org>2024-01-30 11:15:46 +0100
commitf74b5c5bc67c3c1df799e5dd073a441984953b44 (patch)
treee99534d92dd1e5650e09dbcb34d029d768a2abe1
parent6fc8a7b2b03bfcb26e2e7440251b6f17e01210c8 (diff)
downloadpostgresql-f74b5c5bc67c3c1df799e5dd073a441984953b44.tar.gz
postgresql-f74b5c5bc67c3c1df799e5dd073a441984953b44.zip
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
-rw-r--r--contrib/pgcrypto/pgp-decrypt.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/contrib/pgcrypto/pgp-decrypt.c b/contrib/pgcrypto/pgp-decrypt.c
index d12dcad1945..e1ea5b3e58d 100644
--- a/contrib/pgcrypto/pgp-decrypt.c
+++ b/contrib/pgcrypto/pgp-decrypt.c
@@ -250,7 +250,8 @@ prefix_init(void **priv_p, void *arg, PullFilter *src)
uint8 tmpbuf[PGP_MAX_BLOCK + 2];
len = pgp_get_cipher_block_size(ctx->cipher_algo);
- if (len > sizeof(tmpbuf))
+ /* Make sure we have space for prefix */
+ if (len > PGP_MAX_BLOCK)
return PXE_BUG;
res = pullf_read_max(src, len + 2, &buf, tmpbuf);