| From: | Prashant Chinnam <crprashant(at)hotmail(dot)com> |
|---|---|
| To: | "zsolt(dot)parragi(at)percona(dot)com" <zsolt(dot)parragi(at)percona(dot)com>, "Ideriha, Takeshi" <iderihatakeshi(at)gmail(dot)com> |
| Cc: | "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
| Subject: | Re: [PATCH] pgcrypto: Fix sha-crypt rounds= values that do not fit in int (BUG #19743) |
| Date: | 2026-12-02 21:42:02 |
| Message-ID: | SN7P223MB06008BE246E259E59A14C320DD4C2@SN7P223MB0600.NAMP223.PROD.OUTLOOK.COM |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Zsolt,
>This is mostly nitpicking, but:
>SELECT crypt('sample', '$5$rounds=' || repeat(' ', 10) || '5$abc') =
>crypt('sample', '$5$rounds=1000$abc');
>-- patched: NOTICE: rounds= ... is below supported value
>(1000), using 1000 instead
>-- master: NOTICE: rounds=5 is below supported value (1000), using
>1000 instead
>is this definitely an improvement?
Good catch you're right, that one is worse than master.
strtoint() skips leading whitespace when it parses, so a token
of ten spaces followed by "5" parses as 5, and the clamp itself
is correct: 5 is below the supported minimum, so 1000 rounds
are used. But the NOTICE echo starts at the raw token, so the
spaces count toward the 10-character cap and the digit never
appears : the message reads "rounds= ..." instead of
"rounds=5 ...", which tells the reader nothing.
Fixed in the attached v7: leading whitespace is skipped when
computing the echoed slice, so this case now prints "rounds=5
is below supported value (1000), using 1000 instead". There
is a regression test added for it, built with
repeat(' ', 10) || '5'.
The cap itself is unchanged an overlong digit string still
truncates with "...", as in v6.
Thanks for spotting it.
Hi Takeshi,
Thanks for the review on v6.
Regards,
Prashant
| Attachment | Content-Type | Size |
|---|---|---|
| v7-0001-pgcrypto-Fix-sha-crypt-rounds-values-that-do-not-fit.patch | application/octet-stream | 11.2 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Masahiko Sawada | 2026-12-02 21:59:57 | Re: Postmaster PANIC on a standby with slot synchronization enabled |
| Previous Message | Shlok Kyal | 2026-12-02 21:28:30 | Re: Show the conflict log table in \dRs+ output |