> On Oct 27, 2026, at 09:13, Prashant Chinnam <[email protected]> wrote:
> 
> Hi Takeshi,
> 
> Thanks again for the review and the alternative patch.
> Attached is v2, which adopts your strtoi64 approach as
> discussed.
> 
> The crypt-sha.c change is the one you suggested: parse rounds=
> with strtoi64() so out-of-range values saturate into the
> existing clamping, and report the value as supplied in the
> clamp NOTICEs.  The regression tests are carried over from v1
> unchanged.
> 
> Behaviour is identical to v1 on the full test battery,
> including the values beyond int64 in both directions, and the
> pgcrypto regression suite passes 25/25.
> 
> As noted before, sha-crypt support exists only in PG 18 and
> master, so backpatching to REL_18_STABLE should be considered.
> 
> Testing was done with AI assistance.
> 
> Regards,
> Prashant 
> Chinnam<v2-0001-pgcrypto-Fix-sha-crypt-rounds-values-that-do-not-fit.patch>

I think strtoi64() works properly here. It maps to strtol() or strtoll(), 
depending on the platform. According to the man page [1], on overflow, it 
returns INT64_MAX or INT64_MIN. Both values are outside the supported range 
(PX_SHACRYPT_ROUNDS_MIN, PX_SHACRYPT_ROUNDS_MAX), so srounds will be clamped 
correctly.

Another thing the patch does is change the NOTICE message to print the original 
input string, which is good in most cases. A small concern is: what if the 
input string is unreasonably long? Maybe we should cap the maximum length of 
the printed string?

[1] https://man7.org/linux/man-pages/man3/strtol.3p.html

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/






Reply via email to