]> granicus.if.org Git - postgresql/commitdiff
Add forgotten CHECK_FOR_INTERRUPT calls in pgcrypto's crypt()
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Sun, 27 Dec 2015 16:03:19 +0000 (13:03 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Sun, 27 Dec 2015 16:03:19 +0000 (13:03 -0300)
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.

contrib/pgcrypto/crypt-blowfish.c
contrib/pgcrypto/crypt-des.c

index 4054e6a06fc758e2bd388080ee0b6aeb523de42e..6feaefcf7be10ff7bf54058c7c76b08ff809470c 100644 (file)
@@ -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];
index 682958600a6818775f533d3978ceb08fd9243941..a4aa4966bfcc01a2d5f82bcdb4d833a7a1d1523c 100644 (file)
@@ -61,6 +61,7 @@
  */
 
 #include "postgres.h"
+#include "miscadmin.h"
 
 #include "px-crypt.h"
 
@@ -540,6 +541,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.
                 */