Index: contrib/pgcrypto/px.c =================================================================== RCS file: /projects/cvsroot/pgsql/contrib/pgcrypto/px.c,v retrieving revision 1.15 diff -p -u -r1.15 px.c --- contrib/pgcrypto/px.c 15 Oct 2005 02:49:06 -0000 1.15 +++ contrib/pgcrypto/px.c 23 Aug 2007 08:50:16 -0000 @@ -58,6 +58,7 @@ static const struct error_desc px_err_li {PXE_BAD_SALT_ROUNDS, "Incorrect number of rounds"}, {PXE_MCRYPT_INTERNAL, "mcrypt internal error"}, {PXE_NO_RANDOM, "No strong random source"}, + {PXE_DECRYPT_FAILED, "Decryption failed"}, {PXE_PGP_CORRUPT_DATA, "Wrong key or corrupt data"}, {PXE_PGP_CORRUPT_ARMOR, "Corrupt ascii-armor"}, {PXE_PGP_UNSUPPORTED_COMPR, "Unsupported compression algorithm"}, @@ -279,6 +280,18 @@ combo_decrypt(PX_Combo * cx, const uint8 PX_Cipher *c = cx->cipher; + /* decide whether zero-length input is allowed */ + if (dlen == 0) + { + /* with padding, empty ciphertext is not allowed */ + if (cx->padding) + return PXE_DECRYPT_FAILED; + + /* without padding, report empty result */ + *rlen = 0; + return 0; + } + bs = px_cipher_block_size(c); if (bs > 1 && (dlen % bs) != 0) goto block_error; Index: contrib/pgcrypto/px.h =================================================================== RCS file: /projects/cvsroot/pgsql/contrib/pgcrypto/px.h,v retrieving revision 1.17 diff -p -u -r1.17 px.h --- contrib/pgcrypto/px.h 6 Apr 2007 05:36:50 -0000 1.17 +++ contrib/pgcrypto/px.h 23 Aug 2007 08:50:16 -0000 @@ -78,6 +78,7 @@ void px_free(void *p); #define PXE_BAD_SALT_ROUNDS -15 #define PXE_MCRYPT_INTERNAL -16 #define PXE_NO_RANDOM -17 +#define PXE_DECRYPT_FAILED -18 #define PXE_MBUF_SHORT_READ -50