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.98.2) (envelope-from ) id 1xSvCG-00000002F7Y-2hC0 for pgsql-bugs@arkaria.postgresql.org; Mon, 16 Nov 2026 11:48:28 +0000 Received: from localhost ([127.0.0.1]:55142 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xSvCF-00000000tuz-22Zu for pgsql-bugs@arkaria.postgresql.org; Mon, 16 Nov 2026 11:48:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]:39782) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xSSBs-0000000EojW-0H1p for pgsql-bugs@lists.postgresql.org; Sun, 15 Nov 2026 04:50:08 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xSSBq-000000017Bq-0cBp for pgsql-bugs@lists.postgresql.org; Sun, 15 Nov 2026 04:50:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=voTA0fTFQ6IPN6HNGMOrMWJ7DsNyC1sCJGsgvJ2wigE=; b=yCsJ6uYaYLpzJWW0XCEnWErvMn 3J87IRIoenQW7lCuGcbo8cQpXUP4zM4ZXRDauFiL63PXeFJnEEG/Lp8Zv06K5HrrQ3pFhahLmUa/y gy2u45jaxr/LeVFTJhUMYOWHXy+RcIVLYIpnEO59ls8/oC/mAumd0AYHlZWFQfYVIMkvX9ugTLZ8M 8v9qEF8Ky9qfKokYMhkV8rjMI5SHf31itxCBvc6tTT4p7TENyEWOM3brjiMuTtKg34fl/Su7USagP cwucVOKvgu9mAFhl99GYe/TsaKTctKtx0MolBOwW0E+ZAf1lHMdDxXsdDaq8kT4hrKZPZloJZKB5r aRvct+uA==; Received: from wrigleys.postgresql.org ([2a02:16a8:dc51::60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xSSBo-00000002nUt-1fC8 for pgsql-bugs@lists.postgresql.org; Sun, 15 Nov 2026 04:50:04 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xSSBn-00000006xrW-23W6 for pgsql-bugs@lists.postgresql.org; Sun, 15 Nov 2026 04:50:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19905: loread() with length near INT_MAX: "invalid memory alloc request size" (int32 overflow) To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: hackerzheng666@gmail.com Reply-To: hackerzheng666@gmail.com, pgsql-bugs@lists.postgresql.org Date: Sun, 15 Nov 2026 04:49:11 +0000 Message-ID: <19905-3f33374cbee82db1@postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk The following bug has been logged on the website: Bug reference: 19905 Logged by: Zheng Hacker Email address: hackerzheng666@gmail.com PostgreSQL version: 19rc2 Operating system: Linux x86_64 (Ubuntu 22.04) Description: =20 Tested on git master (20devel, commit 70c4a57b64d3; the code in question is unchanged at master 81b2179 as of 2026-11-14). Not tested on 19rc2 or older branches; the version selected in the form is only the closest listed one. select loread(2147483647, 2147483647); ERROR: invalid memory alloc request size 18446744071562067971 In src/backend/libpq/be-fsstubs.c, be_loread() (the SQL function loread) does retval =3D (bytea *) palloc(VARHDRSZ + len); with "int len". For len > INT_MAX - VARHDRSZ the sum overflows to a negative int and is converted to a huge size_t, so the user sees an internal-looking error with a nonsensical size instead of a clean limit error. Clamping len to MaxAllocSize - VARHDRSZ (or raising "requested length too large" before the allocation, as lo_get() style paths do) would give a proper message.