0001-Add-CHECK_FOR_INTERRUPTS-in-scram_SaltedPassword-loo.patch
application/octet-stream
Filename: 0001-Add-CHECK_FOR_INTERRUPTS-in-scram_SaltedPassword-loo.patch
Type: application/octet-stream
Part: 0
Patch
Format: format-patch
Series: patch 0001
Subject: Add CHECK_FOR_INTERRUPTS in scram_SaltedPassword loop.
| File | + | − |
|---|---|---|
| src/common/scram-common.c | 4 | 0 |
From fc044f08644c960867af385b6d5e38512417bff6 Mon Sep 17 00:00:00 2001
From: bovenshi <bovenshi@tencent.com>
Date: Wed, 22 Nov 2023 19:30:56 +0800
Subject: [PATCH] Add CHECK_FOR_INTERRUPTS in scram_SaltedPassword loop.
When the scram_iterations value is set too large, the backend would hang for
a long time. Add CHECK_FOR_INTERRUPTS within the loop of scram_SaltedPassword
to handle any signals received during this period.
---
src/common/scram-common.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/common/scram-common.c b/src/common/scram-common.c
index ef997ef..cf29c76 100644
--- a/src/common/scram-common.c
+++ b/src/common/scram-common.c
@@ -15,6 +15,7 @@
*/
#ifndef FRONTEND
#include "postgres.h"
+#include "miscadmin.h"
#else
#include "postgres_fe.h"
#endif
@@ -73,6 +74,9 @@ scram_SaltedPassword(const char *password,
/* Subsequent iterations */
for (i = 2; i <= iterations; i++)
{
+#ifndef FRONTEND
+ CHECK_FOR_INTERRUPTS();
+#endif
if (pg_hmac_init(hmac_ctx, (uint8 *) password, password_len) < 0 ||
pg_hmac_update(hmac_ctx, (uint8 *) Ui_prev, key_length) < 0 ||
pg_hmac_final(hmac_ctx, Ui, key_length) < 0)
--
2.9.3