• Tom Lane's avatar
    Remove arbitrary restrictions on password length. · 67a472d7
    Tom Lane authored
    This patch started out with the goal of harmonizing various arbitrary
    limits on password length, but after awhile a better idea emerged:
    let's just get rid of those fixed limits.
    
    recv_password_packet() has an arbitrary limit on the packet size,
    which we don't really need, so just drop it.  (Note that this doesn't
    really affect anything for MD5 or SCRAM password verification, since
    those will hash the user's password to something shorter anyway.
    It does matter for auth methods that require a cleartext password.)
    
    Likewise remove the arbitrary error condition in pg_saslprep().
    
    The remaining limits are mostly in client-side code that prompts
    for passwords.  To improve those, refactor simple_prompt() so that
    it allocates its own result buffer that can be made as big as
    necessary.  Actually, it proves best to make a separate routine
    pg_get_line() that has essentially the semantics of fgets(), except
    that it allocates a suitable result buffer and hence will never
    return a truncated line.  (pg_get_line has a lot of potential
    applications to replace randomly-sized fgets buffers elsewhere,
    but I'll leave that for another patch.)
    
    I built pg_get_line() atop stringinfo.c, which requires moving
    that code to src/common/; but that seems fine since it was a poor
    fit for src/port/ anyway.
    
    This patch is mostly mine, but it owes a good deal to Nathan Bossart
    who pressed for a solution to the password length problem and
    created a predecessor patch.  Also thanks to Peter Eisentraut and
    Stephen Frost for ideas and discussion.
    
    Discussion: https://postgr.es/m/09512C4F-8CB9-4021-B455-EF4C4F0D55A0@amazon.com
    67a472d7
vacuumlo.c 13.5 KB