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 1uLVuL-00Akfa-Cz for pgsql-bugs@arkaria.postgresql.org; Sat, 31 May 2025 23:46:33 +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 1uLVuI-00GasW-TS for pgsql-bugs@arkaria.postgresql.org; Sat, 31 May 2025 23:46:30 +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 1uLVuI-00GasE-Ky for pgsql-bugs@lists.postgresql.org; Sat, 31 May 2025 23:46:30 +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 1uLVuG-000wSn-1c for pgsql-bugs@lists.postgresql.org; Sat, 31 May 2025 23:46:29 +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 54VNkPvS3020122; Sat, 31 May 2025 19:46:26 -0400 From: Tom Lane To: Daniel Gustafsson cc: Dilip Kumar , stasos24@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18925: Heap-buffer-overflow: pglz_compress with pglz_stategy_always In-reply-to: References: <18925-3b7ab7c50b77c53d@postgresql.org> Comments: In-reply-to Daniel Gustafsson message dated "Wed, 14 May 2025 15:35:08 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3020120.1748735185.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 31 May 2025 19:46:25 -0400 Message-ID: <3020121.1748735185@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Daniel Gustafsson writes: > The way I read it there is now way to reproduce this as the codepath use= d in > the fuzzer ins't present in postgres (PGLZ_strategy_always is not used b= y any > callsite). > Whether or not there is a bug in the compression code, or PGLZ_strategy_= always > being incorrectly defined, or none of the above, remains to be seen. I think the bug is in the test program: it's allocating an output buffer of the same size as the input buffer. This does not conform to the API spec for pglz_compress: * int32 * pglz_compress(const char *source, int32 slen, char *dest, * const PGLZ_Strategy *strategy); * * source is the input data to be compressed. * * slen is the length of the input data. * * dest is the output area for the compressed result. * It must be at least as big as PGLZ_MAX_OUTPUT(slen). PGLZ_MAX_OUTPUT adds 4 bytes to the size, which the test program is not doing, so an output buffer overrun can be expected no matter which strategy is selected. regards, tom lane