Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ioKmK-0005WM-7j for pgsql-bugs@arkaria.postgresql.org; Mon, 06 Jan 2020 05:18:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ioKmI-0003Wc-PP for pgsql-bugs@arkaria.postgresql.org; Mon, 06 Jan 2020 05:18:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ioKmI-0003WV-HI for pgsql-bugs@lists.postgresql.org; Mon, 06 Jan 2020 05:18:10 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ioKmG-0007pF-8l for pgsql-bugs@lists.postgresql.org; Mon, 06 Jan 2020 05:18:10 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id D6FEE49C; Mon, 6 Jan 2020 00:18:05 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 06 Jan 2020 00:18:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=CV7f0r4KDFx2O9h//KA8Uaugh0O OX8524e7KlVJ2q2s=; b=jPcZCwZ5CC9pKCRlRnd8fjY/ACqWFtCT1U/nQ5Z169B 2p2xLpCXFofO8bV9o0PWesqVf2RSJMSZ/cePT8sA/kCYXqAIO5XxlUcTiRbwOFfd nb8UEwJPfGHmoNl/yfd/Kh9TBkry6/ou4hCgYcKmxNc9P3+XYB9/crhbiG8mra8q J0L7d7yeoWf2roJX7OFmNEcXZ0vNtPmYCcCUN/VE4Iu43B1Li1bYL36rAYOIPO7U Z2tflOh1L9KN64RRSFskWtlbhmwN+7vMltt2qPI5G3zkrd0x4prNpBCkYezJNS3F mPVyi6BYEPxWGIYhDuzWgns7EATyBAwBwMtOEkXxWSw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=CV7f0r 4KDFx2O9h//KA8Uaugh0OOX8524e7KlVJ2q2s=; b=Zcnb+BGXADfFOY8EuFI8VE PdIBhGiTFD7wTNqmhTCgdLMaoTz/txPzLe+dLcAJSCV40EKu+nnYa+zL3TixGEaF Ci/FOB+q42LihOFB/sOL59g10FaNU5ZHZGGTBnWryCQ1NHOvSKMBVCsGdYCUIIv4 Pi+rpBVWuUhFN+kV7ioXN2j8UTnnKaUhwH9XNjELL2dazQEbo+FF2gZ4NXl4K0Nf q/NxhGozP9vmGtn7l6h4B5gvlzTGHZg56Kxfo/0OiLO62O8ksxCZuSof9D/PvEUr ueNITALqRVy0ygSIprUeSfds93tyv1vMBMEQyXelQfFIqnOAh4aKXSJcXIuEiiTA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrvdegledgkedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgfrhhlucfvnfffucdljedtmdenucfjughrpeffhf fvuffkfhggtggujgesghdtreertddtjeenucfhrhhomhepofhitghhrggvlhcurfgrqhhu ihgvrhcuoehmihgthhgrvghlsehprghquhhivghrrdighiiiqeenucfkphepudduuddrud dtvddrudektddrudekheenucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhes phgrqhhuihgvrhdrgiihiienucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from paquier.xyz (ee0822lan1.rev.em-net.ne.jp [111.102.180.185]) by mail.messagingengine.com (Postfix) with ESMTPA id 7F73E80059; Mon, 6 Jan 2020 00:18:03 -0500 (EST) Date: Mon, 6 Jan 2020 14:18:00 +0900 From: Michael Paquier To: starbugs@qq.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16190: The usage of NULL pointer in refint.c Message-ID: <20200106051800.GL3598@paquier.xyz> References: <16190-70181c803641c3dc@postgresql.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="1rguoi8KZGYj2k4L" Content-Disposition: inline In-Reply-To: <16190-70181c803641c3dc@postgresql.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --1rguoi8KZGYj2k4L Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jan 06, 2020 at 03:39:36AM +0000, PG Bug reporting form wrote: > We checked the code in file =E2=80=9Crefint.c=E2=80=9D and there is one e= rror occurring in > line 636. This error is caused by the usage of pointer with NULL value. T= he > code in this line is =E2=80=9Cnewp->ident =3D strdup(ident);=E2=80=9D The= pointer =E2=80=9Cnewp=E2=80=9D is > defined by the code in line 615 as =E2=80=9CEPlan *newp;=E2=80=9D and ini= tialized by the > code in line 628 as =E2=80=9Cnewp =3D *eplan + i;=E2=80=9D or in line 632= as =E2=80=9Cnewp =3D *eplan =3D > (EPlan *) malloc(sizeof(EPlan));=E2=80=9D according to different conditio= ns. In the > first condition, the =E2=80=9C*eplan=E2=80=9D is valued by the code =E2= =80=9C*eplan =3D (EPlan *) > realloc(*eplan, (i + 1) * sizeof(EPlan));=E2=80=9D in line 627. We found = the code > hasn=E2=80=99t checked if the process =E2=80=9Crealloc=E2=80=9D and =E2= =80=9Cmalloc=E2=80=9D are success or not > which directly define the value of =E2=80=9C*eplan=E2=80=9D. The program = should check the > effectiveness of the return value of function =E2=80=9Crealloc=E2=80=9D a= nd =E2=80=9Cmalloc=E2=80=9D to > avoid this error. It could be better to switch all that to not use directly system calls, and rely properly on a high-level memory context with palloc-like allocations. There could be also an argument to just remove the module per the lack of attention it is getting, though it is still useful as an example of use for SPI, and the docs mention it for that. -- Michael --1rguoi8KZGYj2k4L Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAl4SwwgACgkQnvQgOdby QH3uzA/7BSRKFW4rzedXjfpvpl8OwXQiKoYmVkZ5Uea6hpQ0dkLVABLkhCKfGL5m MHQ8W84nTxzsDyczPo9XE7nB7FKMoJEqUaJpIqyIaDsPws+WBFKXQmJSZmGGG1/1 C3/ouNt9mOe+RKSQyYpGHq1x5EEyNs2LeX979YIa/iNX/wXrCvVV+Z9kJoMZOuhU SwHiSDgV98Ql6WqBxtB91OsywHy+1ZyT3MbZi0oD2jEB25y3svMgVLA1PysgsHi4 VppFdQzLa2vbMkxAzXXRHf26+pG7Rw+bYen+29o2Gbt24Qi7Z9yt4dt2NnJeCZ1R RU76EiR0/fVn/cjVheXLSDVlbNmm1R2Bd/0hXhAcDE2Fz22zj/4073kfWkEjdaci qKbAP5lFdXiqt14HzeARWEMa7MK0qXT0FI6IIF+vWVswvEDxq/ct/GeziKnPjnva F/Net56igapG3LIKMwrlomCttkYen5qlYWUt8pVpr5+9aQy27Ew+R3gIRVmQiPXW nJ7SKLl4Mu97yfEoDbjDr4n1RDjS/UNc5h/nUkV7ozAx0Wj79pT6/qOk0MSqHou7 ZzMvafrB0ge+eln13MNWv6lWhlxFgh9+opfx2NfRUII66YaKnNT7gddfykM2QXft 0XyaLc1NkCLO1Q8tppKu6mwmKaESN1AkdKcGo1IISe3IZqbTdog= =G/U2 -----END PGP SIGNATURE----- --1rguoi8KZGYj2k4L--