Re: [PATCH] libpq: Add PQpassfileLookup() - Mailing list pgsql-hackers

From Denis Smirnov
Subject Re: [PATCH] libpq: Add PQpassfileLookup()
Date
Msg-id D35D0ABB-755E-4EDE-B535-5C7578B3D3DC@gmail.com
Whole thread
In response to Re: [PATCH] libpq: Add PQpassfileLookup()  (Diego <mrstephenamell@gmail.com>)
Responses Re: [PATCH] libpq: Add PQpassfileLookup()
List pgsql-hackers
Hi Diego,

Thanks for v2!

>  * The returned allocation contains a plaintext password.
>    PQfreemem() does not erase it, whereas libpq explicitly clears
>    passwords stored in PGconn before freeing them.  It would be useful
>    for the documentation to mention that callers are responsible for
>    securely clearing the result where appropriate.

The new docs now say this, but passwordFromFile() leaves part of the
original password after removing escapes in place:

    Password in .pgpass: pa\\ss\:word
    Returned buffer:    pa\ss:word\0d\0

A caller using explicit_bzero(password, strlen(password)) before
PQfreemem() leaves the final 'd' untouched. Could we zero this tail in
passwordFromFile() before returning? The caller does not know the
original allocation size.


Best regards,
Denis Smirnov




pgsql-hackers by date:

Previous
From: Alexander Lakhin
Date:
Subject: Re: Internal error codes triggered by regression tests and user queries, take 2
Next
From: Vaibhav Dalvi
Date:
Subject: Re: Add PRODUCT() aggregate function