Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit14f2f9e

Browse files
committed
Add CHECK_FOR_INTERRUPTS() in scram_SaltedPassword() for the backend
scram_SaltedPassword() could take a long time to compute when the numberof iterations used is large enough, and this code uses a tight loop tocompute a salted password.Note that the same issue exists in libpq when using \password and alarge iteration number, but this cannot be interrupted. A CFI in thebackend is useful for server-side computations, at least.Backpatch down to 16, where the user-settable GUC scram_iterations hasbeen added.Author: Bowen ShiReviewed-by: Aleksander Alekseev, Daniel GustafssonDiscussion:https://postgr.es/m/CAM_vCueV6xfr08KczfaCEk5J_qeTZtgqN7+orkNLx=g+phE82Q@mail.gmail.comBackpatch-through: 16
1 parent930d2b4 commit14f2f9e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

‎src/common/scram-common.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
#include"common/base64.h"
2323
#include"common/hmac.h"
2424
#include"common/scram-common.h"
25+
#ifndefFRONTEND
26+
#include"miscadmin.h"
27+
#endif
2528
#include"port/pg_bswap.h"
2629

2730
/*
@@ -73,6 +76,14 @@ scram_SaltedPassword(const char *password,
7376
/* Subsequent iterations */
7477
for (i=2;i <=iterations;i++)
7578
{
79+
#ifndefFRONTEND
80+
/*
81+
* Make sure that this is interruptible as scram_iterations could be
82+
* set to a large value.
83+
*/
84+
CHECK_FOR_INTERRUPTS();
85+
#endif
86+
7687
if (pg_hmac_init(hmac_ctx, (uint8*)password,password_len)<0||
7788
pg_hmac_update(hmac_ctx, (uint8*)Ui_prev,key_length)<0||
7889
pg_hmac_final(hmac_ctx,Ui,key_length)<0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp