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 1lyIoW-0003Oi-8h for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Jun 2021 18:50:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lyIoU-0007Gx-Sf for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Jun 2021 18:50:26 +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 1lyIoU-0007Go-L1 for pgsql-hackers@lists.postgresql.org; Tue, 29 Jun 2021 18:50:26 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lyIoS-0002PL-Dv for pgsql-hackers@postgresql.org; Tue, 29 Jun 2021 18:50:26 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 15TIoKmk497375; Tue, 29 Jun 2021 14:50:20 -0400 From: Tom Lane To: Jacob Champion cc: "michael@paquier.xyz" , "daniel@yesql.se" , "pgsql-hackers@postgresql.org" Subject: Re: [PATCH] Make jsonapi usable from libpq In-reply-to: References: Comments: In-reply-to Jacob Champion message dated "Tue, 29 Jun 2021 18:09:54 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <497373.1624992620.1@sss.pgh.pa.us> Date: Tue, 29 Jun 2021 14:50:20 -0400 Message-ID: <497374.1624992620@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Jacob Champion writes: > What would you think about a src/port of asprintf()? Maybe libpq > doesn't change quickly enough to worry about it, but having developers > revisit stack allocation for strings every time they target the libpq > parts of the code seems like a recipe for security problems. The existing convention is to use pqexpbuffer.c, which seems strictly cleaner and more robust than asprintf. In particular its behavior under OOM conditions is far easier/safer to work with. Maybe we should consider moving that into src/common/ so that it can be used by code that's not tightly bound into libpq? regards, tom lane