From: | Michael Paquier <michael(at)paquier(dot)xyz> |
---|---|
To: | "Jonathan S(dot) Katz" <jkatz(at)postgresql(dot)org> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)lists(dot)postgresql(dot)org, Stephen Frost <sfrost(at)snowman(dot)net> |
Subject: | Re: Possible to store invalid SCRAM-SHA-256 Passwords |
Date: | 2019-04-23 01:01:42 |
Message-ID: | 20190423010142.GE2712@paquier.xyz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Mon, Apr 22, 2019 at 07:36:45PM -0400, Jonathan S. Katz wrote:
> On 4/22/19 6:42 PM, Tom Lane wrote:
>> Yeah, that's silly; why not
>>
>> strspn(shadow_pass + 3, MD5_PASSWD_CHARSET) == MD5_PASSWD_LEN - 3
>>
>> It's not like this code isn't very well aware of the first 3 characters
>> being not like the others.
>
> I like that :) Please see attached patch, which is diff'd from the one
> upthread.
That's exactly what I would have done for that. However...
+ if (strncmp(shadow_pass, "md5", 3) == 0 && strlen(shadow_pass) == MD5_PASSWD_LEN &&
+ strspn(shadow_pass + 3, MD5_PASSWD_CHARSET) == MD5_PASSWD_LEN - 3)
return PASSWORD_TYPE_MD5;
There is no point for the second strlen() check, as strspn does the
same work.
Also, the extra SELECT query with regexp_replace() is a bit overkill
for the purpose, and copying again a copy of the regexp around is no
fun.
In short, I would simplify things as the attached. What do you think?
--
Michael
Attachment | Content-Type | Size |
---|---|---|
scram-md5-invalid.patch | text/x-diff | 6.2 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2019-04-23 01:10:49 | Re: Possible to store invalid SCRAM-SHA-256 Passwords |
Previous Message | Michael Paquier | 2019-04-23 00:06:19 | Re: Possible to store invalid SCRAM-SHA-256 Passwords |