Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJHqo-0006jF-9T for pgsql-bugs@arkaria.postgresql.org; Mon, 27 Nov 2017 11:45:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJHqn-0007Ux-OW for pgsql-bugs@arkaria.postgresql.org; Mon, 27 Nov 2017 11:45:25 +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_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eJHpj-0007OD-Es for pgsql-bugs@lists.postgresql.org; Mon, 27 Nov 2017 11:44:19 +0000 Received: from m12-17.163.com ([220.181.12.17]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eJHpf-0001Xp-3U for pgsql-bugs@postgresql.org; Mon, 27 Nov 2017 11:44:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Date:From:Subject:Message-ID:MIME-Version; bh=RJF+8 Pcmu/SkOlWUiWFe3d3kZwOEAXCAVcrSRuh9zMc=; b=IO2n0qMiNuQ4OFM54BBly uAEVTRSQfw/Zerwxzd7PAewmn5CihtW2bEMMVV8lSvYH0oxGKfx3RNbYpgsgYFhy gAc4LmJPW6HocyL4BeQKlHk+VNy0SIr6pHEHiMZC7I9Le85TmAL4xJRYDtOtGfrT GWSw/cyUu0RN38Zn9IbCoU= Received: from bp (unknown [106.120.213.112]) by smtp13 (Coremail) with SMTP id EcCowAAnh8eL+hta4nD1BQ--.9566S2; Mon, 27 Nov 2017 19:44:11 +0800 (CST) Date: Mon, 27 Nov 2017 19:44:10 +0800 From: PanBian To: Michael Paquier , Amit Langote Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #14929: Unchecked AllocateDir() return value in restoreTwoPhaseData() Message-ID: <20171127114410.GA30545@bp> Reply-To: PanBian References: <20171127093107.1473.70477@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-CM-TRANSID: EcCowAAnh8eL+hta4nD1BQ--.9566S2 X-Coremail-Antispam: 1Uf129KBjvdXoW7XFyrJFyUXr15ZF1xtr13Jwb_yoWxurg_W3 97XFZ2ywn3Ar18Kw4fKrWIvrW3uF1UCrWxCwn5Kr1xtas3Zws8WFWqg3s8Zr4xCFZ7tryD Wrn09Fyagw4IkjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU0uc_3UUUUU== X-Originating-IP: [106.120.213.112] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/xtbBZAudclQG+dDJjQAAs- List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Nov 27, 2017 at 07:53:30PM +0900, Michael Paquier wrote: > On Mon, Nov 27, 2017 at 6:31 PM, wrote: > > AllocateDir() will return a NULL pointer if it fails to open the specified > > directory. However, in function restoreTwoPhaseData(), its return value is > > not checked. This may result in a NULL pointer dereference when trying to > > free it (see line 1759). > > You are missing the fact that ReadDir goes through ReadDirExtended, > which drops an ERROR log if the folder allocated is NULL. You are right. Its my carelessness. ReadDir will not return back on a NULL dir parameter. The code is bug free. Sorry for the trouble. Thank you all, Pan Bian > -- > Michael