diff options
author | Richard Guo <rguo@postgresql.org> | 2025-03-26 17:46:51 +0900 |
---|---|---|
committer | Richard Guo <rguo@postgresql.org> | 2025-03-26 17:46:51 +0900 |
commit | 7c82b4f711877b175142bb2b2a6e2c2ee2429441 (patch) | |
tree | 3bb928505abaf48be9b042e6df2d753b59a9075e /src/common/scram-common.c | |
parent | 787514b30bb7dd0b3484d6cb717e3b9aafc06c4a (diff) | |
download | postgresql-7c82b4f711877b175142bb2b2a6e2c2ee2429441.tar.gz postgresql-7c82b4f711877b175142bb2b2a6e2c2ee2429441.zip |
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
Diffstat (limited to 'src/common/scram-common.c')
-rw-r--r-- | src/common/scram-common.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/common/scram-common.c b/src/common/scram-common.c index 400900c51c5..bfd2a340016 100644 --- a/src/common/scram-common.c +++ b/src/common/scram-common.c @@ -74,7 +74,7 @@ scram_SaltedPassword(const char *password, memcpy(result, Ui_prev, key_length); /* Subsequent iterations */ - for (i = 2; i <= iterations; i++) + for (i = 1; i < iterations; i++) { #ifndef FRONTEND /* |