From a56e0e28b6e368614248754fad4d1dec96b4094c Mon Sep 17 00:00:00 2001 From: Takeshi Ideriha Date: Mon, 26 Oct 2026 15:24:23 +0900 Subject: [PATCH v1] Fix clamp behaviour when rounds is out of bounds of integer in pgcrypto --- contrib/pgcrypto/crypt-sha.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contrib/pgcrypto/crypt-sha.c b/contrib/pgcrypto/crypt-sha.c index dfdea1f9bcf..60c9c0c973d 100644 --- a/contrib/pgcrypto/crypt-sha.c +++ b/contrib/pgcrypto/crypt-sha.c @@ -186,7 +186,7 @@ px_crypt_shacrypt(const char *pw, const char *salt, char *passwd, unsigned dstle { const char *num = dec_salt_binary + sizeof(rounds_prefix) - 1; char *endp; - int srounds = strtoint(num, &endp, 10); + int64 srounds = strtoi64(num, &endp, 10); if (*endp != '$') ereport(ERROR, @@ -210,8 +210,8 @@ px_crypt_shacrypt(const char *pw, const char *salt, char *passwd, unsigned dstle { ereport(NOTICE, errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), - errmsg("rounds=%d exceeds maximum supported value (%d), using %d instead", - srounds, PX_SHACRYPT_ROUNDS_MAX, + errmsg("rounds=%.*s exceeds maximum supported value (%d), using %d instead", + (int) (endp - num), num, PX_SHACRYPT_ROUNDS_MAX, PX_SHACRYPT_ROUNDS_MAX)); srounds = PX_SHACRYPT_ROUNDS_MAX; } @@ -219,8 +219,8 @@ px_crypt_shacrypt(const char *pw, const char *salt, char *passwd, unsigned dstle { ereport(NOTICE, errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), - errmsg("rounds=%d is below supported value (%d), using %d instead", - srounds, PX_SHACRYPT_ROUNDS_MIN, + errmsg("rounds=%.*s is below supported value (%d), using %d instead", + (int) (endp - num), num, PX_SHACRYPT_ROUNDS_MIN, PX_SHACRYPT_ROUNDS_MIN)); srounds = PX_SHACRYPT_ROUNDS_MIN; } -- 2.50.1 (Apple Git-155)