summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2015-12-27 13:03:19 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2015-12-27 13:03:19 -0300
commit1b6102eb73f4483eb30f3008b07882a93ff369f8 (patch)
tree6de6a320345184ce573d7887bbf347c7fa6c08e0
parent7e29e7f5544d41cdf3cc2ed209ecabfa0242af04 (diff)
downloadpostgresql-1b6102eb73f4483eb30f3008b07882a93ff369f8.tar.gz
Add forgotten CHECK_FOR_INTERRUPT calls in pgcrypto's crypt()
Both Blowfish and DES implementations of crypt() can take arbitrarily long time, depending on the number of rounds specified by the caller; make sure they can be interrupted. Author: Andreas Karlsson Reviewer: Jeff Janes Backpatch to 9.1.
-rw-r--r--contrib/pgcrypto/crypt-blowfish.c3
-rw-r--r--contrib/pgcrypto/crypt-des.c3
2 files changed, 6 insertions, 0 deletions
diff --git a/contrib/pgcrypto/crypt-blowfish.c b/contrib/pgcrypto/crypt-blowfish.c
index aec7c00cdb..dc88593bc1 100644
--- a/contrib/pgcrypto/crypt-blowfish.c
+++ b/contrib/pgcrypto/crypt-blowfish.c
@@ -33,6 +33,7 @@
*/
#include "postgres.h"
+#include "miscadmin.h"
#include "px-crypt.h"
#include "px.h"
@@ -670,6 +671,8 @@ _crypt_blowfish_rn(const char *key, const char *setting,
do
{
+ CHECK_FOR_INTERRUPTS();
+
data.ctx.P[0] ^= data.expanded_key[0];
data.ctx.P[1] ^= data.expanded_key[1];
data.ctx.P[2] ^= data.expanded_key[2];
diff --git a/contrib/pgcrypto/crypt-des.c b/contrib/pgcrypto/crypt-des.c
index 6834c28cf2..e2501787a0 100644
--- a/contrib/pgcrypto/crypt-des.c
+++ b/contrib/pgcrypto/crypt-des.c
@@ -61,6 +61,7 @@
*/
#include "postgres.h"
+#include "miscadmin.h"
#include "px.h"
#include "px-crypt.h"
@@ -541,6 +542,8 @@ do_des(uint32 l_in, uint32 r_in, uint32 *l_out, uint32 *r_out, int count)
while (count--)
{
+ CHECK_FOR_INTERRUPTS();
+
/*
* Do each round.
*/