Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u5BwD-00De6q-Uy for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Apr 2025 23:13:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1u5BwC-007voS-3t for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Apr 2025 23:13:00 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u5BwB-007voG-Pt for pgsql-hackers@lists.postgresql.org; Wed, 16 Apr 2025 23:13:00 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1u5BwA-000RgO-1W for pgsql-hackers@lists.postgresql.org; Wed, 16 Apr 2025 23:12:59 +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 53GNCq1N2085463; Wed, 16 Apr 2025 19:12:52 -0400 From: Tom Lane To: Michael Paquier cc: Daniel Gustafsson , Ashutosh Bapat , kuznetsovam@altlinux.org, PostgreSQL Developers , egori@altlinux.org, nickel@altlinux.org Subject: Re: pg_dump: Fix dangling pointer in EndCompressorZstd() In-reply-to: References: Comments: In-reply-to Michael Paquier message dated "Wed, 16 Apr 2025 15:29:53 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2085461.1744845172.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 16 Apr 2025 19:12:52 -0400 Message-ID: <2085462.1744845172@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Michael Paquier writes: > On Wed, Apr 16, 2025 at 04:19:02PM +0200, Daniel Gustafsson wrote: >> Agreed, while it's perfectly safe today the end method should not make >> assumptions about the use of the private_data pointer upon return and s= hould >> leave it set to NULL. > Indeed. I was just looking at applying what Alexander has sent > because what EndCompressorZstd() not doing what the other methods do > makes no sense. Perhaps you are already on it, Daniel? I think the actual reason for the difference is that the methods that are taking care to zero the pointer do so because they test the pointer themselves. For instance in EndCompressorGzip, the test is needed because perhaps no data was sent so the struct never got made. It incidentally offers protection against a double call of that function, but I don't think that was the intended reason. I don't have any big objection to zeroing the pointer in EndCompressorZstd, but I think the claim that it's precisely analogous to the other EndCompressor methods is faulty, because it has no similar test. regards, tom lane