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: v7-0001-pgcrypto-Fix-sha-crypt-rounds-values-that-do-not-fit.patch
Description: v7-0001-pgcrypto-Fix-sha-crypt-rounds-values-that-do-not-fit.patch

Reply via email to