Commit 743229a6 authored by Alvaro Herrera's avatar Alvaro Herrera

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.
parent fec1ad94
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
*/ */
#include "postgres.h" #include "postgres.h"
#include "miscadmin.h"
#include "px-crypt.h" #include "px-crypt.h"
#include "px.h" #include "px.h"
...@@ -670,6 +671,8 @@ _crypt_blowfish_rn(const char *key, const char *setting, ...@@ -670,6 +671,8 @@ _crypt_blowfish_rn(const char *key, const char *setting,
do do
{ {
CHECK_FOR_INTERRUPTS();
data.ctx.P[0] ^= data.expanded_key[0]; data.ctx.P[0] ^= data.expanded_key[0];
data.ctx.P[1] ^= data.expanded_key[1]; data.ctx.P[1] ^= data.expanded_key[1];
data.ctx.P[2] ^= data.expanded_key[2]; data.ctx.P[2] ^= data.expanded_key[2];
......
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
*/ */
#include "postgres.h" #include "postgres.h"
#include "miscadmin.h"
#include "px-crypt.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) ...@@ -540,6 +541,8 @@ do_des(uint32 l_in, uint32 r_in, uint32 *l_out, uint32 *r_out, int count)
while (count--) while (count--)
{ {
CHECK_FOR_INTERRUPTS();
/* /*
* Do each round. * Do each round.
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment