Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oiWQQ-0002Cu-Ai for pgsql-hackers@arkaria.postgresql.org; Wed, 12 Oct 2022 07:45:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oiWQO-0001kD-SZ for pgsql-hackers@arkaria.postgresql.org; Wed, 12 Oct 2022 07:45:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oiWQO-0001k3-Ix for pgsql-hackers@lists.postgresql.org; Wed, 12 Oct 2022 07:45:08 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oiWQL-0003Xz-Al for pgsql-hackers@postgresql.org; Wed, 12 Oct 2022 07:45:08 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 657385C00CC; Wed, 12 Oct 2022 03:45:03 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 12 Oct 2022 03:45:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1665560703; x= 1665647103; bh=NW9vgbqVfOOj2bvVD72R/2QTdAmIZmnuBnIt6SqIbgM=; b=q Xko9p4AzlYO5GEcrRdbE4iQNcRLW00fxTE2zaVfuZ+D8tYidbaJ4Yl9yvnRZ7lAb IYzzs7te7vbLT/m4OXuud/r8q5CRU6Dyfy1/GXHODHTaABanod7flKXIBglqa1jy /T2WgUtc9bAvmsOSAf3ncJ+2eF7F9HKHOcxiGJWY5IUrFi2KENkOl5wsA4T9IeMu qdAcDpeP+n18VsMIbvFQvxlSKI6ecf3WsUYgdTbm6Ig6pH87Wyle4VviA4hfEnMP W30vu8afEAZduwqpVO2TkcfVKJOpOfiVgo1YCqqRmdieZxKKQ/H77mJtNyyG/Y2F YWvE4440oPBSqwtA0nvCA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeejjedguddvgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefkffggfgfuvfevfhfhjggtgfesthejredttdefjeenucfhrhhomheprfgv thgvrhcugfhishgvnhhtrhgruhhtuceophgvthgvrhdrvghishgvnhhtrhgruhhtsegvnh htvghrphhrihhsvggusgdrtghomheqnecuggftrfgrthhtvghrnhepheelffeggedujeet iefhleetuddvieffhfffvdejvdffgeejkeduleduheduieefnecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphgvthgvrhdrvghishgvnhhtrhgr uhhtsegvnhhtvghrphhrihhsvggusgdrtghomh X-ME-Proxy: Feedback-ID: i131946ab:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 12 Oct 2022 03:45:02 -0400 (EDT) Message-ID: <3352b18d-7874-b3ce-3fbe-45dda5777e63@enterprisedb.com> Date: Wed, 12 Oct 2022 09:45:01 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: libpq error message refactoring Content-Language: en-US To: Tom Lane Cc: Andres Freund , pgsql-hackers References: <7c0232ef-7b44-68db-599d-b327d0640a77@enterprisedb.com> <20220922154225.q4rtgzzsq6pd4f5x@awork3.anarazel.de> <2032645.1663900649@sss.pgh.pa.us> From: Peter Eisentraut In-Reply-To: <2032645.1663900649@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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.