From: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: libpq error message refactoring
Date: Wed, 12 Oct 2022 09:45:01 +0200
Message-ID: <3352b18d-7874-b3ce-3fbe-45dda5777e63@enterprisedb.com> (raw)
In-Reply-To: <2032645.1663900649@sss.pgh.pa.us>
References: <7c0232ef-7b44-68db-599d-b327d0640a77@enterprisedb.com>
<20220922154225.q4rtgzzsq6pd4f5x@awork3.anarazel.de>
<d5dddca7-9bdc-ee18-1ec9-ee21f8302d4a@enterprisedb.com>
<2032645.1663900649@sss.pgh.pa.us>
On 23.09.22 04:37, Tom Lane wrote:
> Separately from that: is it really okay to delegate use of a va_list
> argument like that? The other call paths of
> appendPQExpBufferVA[_internal] write va_start/va_end directly around it,
> not somewhere else in the call chain. I'm too tired to language-lawyer
> out what happens when you do it like this, but I'm suspecting that it's
> not well-defined portable behavior.
>
> I think what you probably need to do is export appendPQExpBufferVA
> as-is and require libpq_append_error to provide the error loop.
There was actually a live problem here, maybe not the exact one you had
in mind: When you actually need the "need more space" loop, you must do
va_end() and va_start() before calling down again. Otherwise, the next
va_arg() gets garbage.
It so happens that the error message
"private key file \"%s\" has group or world access; file must have
permissions u=rw (0600) or less if owned by the current user, or
permissions u=rw,g=r (0640) or less if owned by root"
together with an in-tree test location for the file in question just
barely exceeds INITIAL_EXPBUFFER_SIZE (256), and so my previous patch
would fail the "ssl" test suite. Good test coverage. :)
Anyway, I have updated my patch with your suggestion, which should fix
these kinds of issues.
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: peter.eisentraut@enterprisedb.com, tgl@sss.pgh.pa.us, andres@anarazel.de
Subject: Re: libpq error message refactoring
In-Reply-To: <3352b18d-7874-b3ce-3fbe-45dda5777e63@enterprisedb.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