Content-Length: 313695 | pFad | http://github.com/postgrespro/postgres/commit/4ddd9e72ffaab50aa755f54e5feffc30a0850930

AF Loop when necessary in contrib/pgcrypto's pktreader_pull(). · postgrespro/postgres@4ddd9e7 · GitHub
Skip to content

Commit 4ddd9e7

Browse files
committed
Loop when necessary in contrib/pgcrypto's pktreader_pull().
This fixes a scenario in which pgp_sym_decrypt() failed with "Wrong key or corrupt data" on messages whose length is 6 less than a power of 2. Per bug #11905 from Connor Penhale. Fix by Marko Tiikkaja, regression test case from Jeff Janes.
1 parent 94d5d57 commit 4ddd9e7

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

contrib/pgcrypto/expected/pgp-decrypt.out

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,3 +364,11 @@ a3nsOzKTXUfS9VyaXo8IrncM6n7fdaXpwba/3tNsAhJG4lDv1k4g9v8Ix2dfv6Rs
364364
(1 row)
365365

366366
-- expected: 7efefcab38467f7484d6fa43dc86cf5281bd78e2
367+
-- check BUG #11905, problem with messages 6 less than a power of 2.
368+
select pgp_sym_decrypt(pgp_sym_encrypt(repeat('x',65530),'1'),'1') = repeat('x',65530);
369+
?column?
370+
----------
371+
t
372+
(1 row)
373+
374+
-- expected: true

contrib/pgcrypto/pgp-decrypt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ pktreader_pull(void *priv, PullFilter *src, int len,
182182
if (pkt->type == PKT_CONTEXT)
183183
return pullf_read(src, len, data_p);
184184

185-
if (pkt->len == 0)
185+
while (pkt->len == 0)
186186
{
187187
/* this was last chunk in stream */
188188
if (pkt->type == PKT_NORMAL)

contrib/pgcrypto/sql/pgp-decrypt.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,3 +264,7 @@ a3nsOzKTXUfS9VyaXo8IrncM6n7fdaXpwba/3tNsAhJG4lDv1k4g9v8Ix2dfv6Rs
264264
-----END PGP MESSAGE-----
265265
'), 'key', 'convert-crlf=1'), 'sha1'), 'hex');
266266
-- expected: 7efefcab38467f7484d6fa43dc86cf5281bd78e2
267+
268+
-- check BUG #11905, problem with messages 6 less than a power of 2.
269+
select pgp_sym_decrypt(pgp_sym_encrypt(repeat('x',65530),'1'),'1') = repeat('x',65530);
270+
-- expected: true

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/4ddd9e72ffaab50aa755f54e5feffc30a0850930

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy