pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Denis Smirnov <darthunix@gmail.com>
To: Grigorev Jurij <ju.grigorev@ftdata.ru>
Cc: Diego <mrstephenamell@gmail.com>
Cc: Jacob Champion <jacob.champion@enterprisedb.com>
Cc: pgsql-hackers@lists.postgresql.org <pgsql-hackers@lists.postgresql.org>
Subject: Re: [PATCH] libpq: Add PQpassfileLookup()
Date: Sun, 13 Sep 2026 12:20:40 +0700
Message-ID: <D35D0ABB-755E-4EDE-B535-5C7578B3D3DC@gmail.com> (raw)
In-Reply-To: <8b93e9c7642b47b49d5b287ed032b00a@localhost.localdomain>
References: <b650e555-11c7-415d-8bda-c747c492ab4a@gmail.com>
	<56a73ea31de54ebea53877367cdd6abf@localhost.localdomain>
	<00e741a7-8dc1-4993-87f4-8976e9c3b6ba@gmail.com>
	<8b93e9c7642b47b49d5b287ed032b00a@localhost.localdomain>

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







view thread (8+ messages)  latest in thread

Message-ID: <D35D0ABB-755E-4EDE-B535-5C7578B3D3DC@gmail.com>
Permalink:  ../D35D0ABB-755E-4EDE-B535-5C7578B3D3DC@gmail.com/
Also on:    postgresql.org/message-id/D35D0ABB-755E-4EDE-B535-5C7578B3D3DC@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: darthunix@gmail.com, ju.grigorev@ftdata.ru, mrstephenamell@gmail.com, jacob.champion@enterprisedb.com, pgsql-hackers@lists.postgresql.org
  Subject: Re: [PATCH] libpq: Add PQpassfileLookup()
  In-Reply-To: <D35D0ABB-755E-4EDE-B535-5C7578B3D3DC@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox