Skip to content

Commit 34fbfe1

Browse files
author
Richard Guo
committed
Fix integer-overflow problem in scram_SaltedPassword()
Setting the iteration count for SCRAM secret generation to INT_MAX will cause an infinite loop in scram_SaltedPassword() due to integer overflow, as the loop uses the "i <= iterations" comparison. To fix, use "i < iterations" instead. Back-patch to v16 where the user-settable GUC scram_iterations has been added. Author: Kevin K Biju <kevinkbiju@gmail.com> Reviewed-by: Richard Guo <guofenglinux@gmail.com> Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/CAM45KeEMm8hnxdTOxA98qhfZ9CzGDdgy3mxgJmy0c+2WwjA6Zg@mail.gmail.com
1 parent f186f90 commit 34fbfe1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/common/scram-common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ scram_SaltedPassword(const char *password,
7474
memcpy(result, Ui_prev, key_length);
7575

7676
/* Subsequent iterations */
77-
for (i = 2; i <= iterations; i++)
77+
for (i = 1; i < iterations; i++)
7878
{
7979
#ifndef FRONTEND
8080
/*

0 commit comments

Comments
 (0)