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 1rMYdz-005Bow-So for pgsql-bugs@arkaria.postgresql.org; Sun, 07 Jan 2024 19:17:12 +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 1rMYdy-00HSA9-Pz for pgsql-bugs@arkaria.postgresql.org; Sun, 07 Jan 2024 19:17:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rMYdy-00HSA0-HR for pgsql-bugs@lists.postgresql.org; Sun, 07 Jan 2024 19:17:10 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rMYdr-000M8C-Tb for pgsql-bugs@lists.postgresql.org; Sun, 07 Jan 2024 19:17:09 +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 407JGx3I1633851; Sun, 7 Jan 2024 14:16:59 -0500 From: Tom Lane To: zuming.jiang@inf.ethz.ch cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18276: Heap-buffer-overflow triggered in src/backend/utils/adt/datum.c:163 In-reply-to: <18276-13b98d6ec97ed5b8@postgresql.org> References: <18276-13b98d6ec97ed5b8@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Sun, 07 Jan 2024 17:50:34 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1633849.1704655019.1@sss.pgh.pa.us> Date: Sun, 07 Jan 2024 14:16:59 -0500 Message-ID: <1633850.1704655019@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > My fuzzer finds a heap-buffer-overflow bug in PostgreSQL 17devel, which > makes PostgreSQL crash. All I see here is a datatype declaration that doesn't match what the C functions expect. You wrote: > CREATE TYPE widget ( > input = widget_in, > output = widget_out, > alignment = double > ); but the declaration that the regress.so functions expect is what's in src/test/regress/sql/create_type.sql: CREATE TYPE widget ( internallength = 24, input = widget_in, output = widget_out, typmod_in = numerictypmodin, typmod_out = numerictypmodout, alignment = double ); That is, widget_in expects it should produce a fixed-length Datum (24 bytes long, with no length word). But you declared the type as variable-length, meaning that datumCopy expects to find a length word. That discrepancy leads directly to the reported crash. regards, tom lane