Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1euKxk-00037U-Jl for pgsql-bugs@arkaria.postgresql.org; Fri, 09 Mar 2018 16:33:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1euKxj-0004x6-K5 for pgsql-bugs@arkaria.postgresql.org; Fri, 09 Mar 2018 16:33:43 +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.89) (envelope-from ) id 1euKxj-0004wx-Dx for pgsql-bugs@lists.postgresql.org; Fri, 09 Mar 2018 16:33:43 +0000 Received: from mout.kundenserver.de ([212.227.126.133]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1euKxh-0000NK-0V for pgsql-bugs@lists.postgresql.org; Fri, 09 Mar 2018 16:33:42 +0000 Received: from feivel.credativ.lan ([107.1.228.194]) by mrelayeu.kundenserver.de (mreue005 [212.227.15.167]) with ESMTPSA (Nemesis) id 0MBo1b-1emJx33bVf-00Ar9V; Fri, 09 Mar 2018 17:33:35 +0100 Received: from localhost (localhost [127.0.0.1]) by feivel.credativ.lan (Postfix) with ESMTP id 636306F3; Fri, 9 Mar 2018 17:33:31 +0100 (CET) Message-ID: <1520613211.2488.140.camel@postgresql.org> Subject: Re: BUG #15104: Double free in the main function in ecpg.c From: Michael Meskes To: bianpan2016@163.com, pgsql-bugs@lists.postgresql.org Date: Fri, 09 Mar 2018 17:33:31 +0100 In-Reply-To: <152056012010.4963.4379808667664715171@wrigleys.postgresql.org> References: <152056012010.4963.4379808667664715171@wrigleys.postgresql.org> Organization: PostgreSQL Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.5-1 Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K0:HNUTDOYO83PX3fSfjeFM0Y8NvyQwiQa/h6+kYOq/2X7qClLi5zy rVdtBRRtfCyNKWPT2lERn9xioxCStGy66bXOwYULZFZ5M5baweKQv2y4Yp3sDm1zyvbj05K OUhAO/w/4IRj9KRma0miJnZBOsXg8XeL9xPfzVCm6jXsFYfPYrd9EAbFrzjWkWd5RRXQRs1 XCnaaWHBOirp2ujDEw5zQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:fzWHCHn0O5M=:AAauZRHrPQT6mn+UaauyuO sLsK7K30re2N1EXf3CK7gQE5r/lqP6MCNMT9SF8oU0BlA6fUXvONkMoR2y7GBsYDej8SBT6U2 XTdnUp+t0FA+n7FewpRitqRmY6B7IG9EJWqYKx/FanuwG63lQmxVZtzItLtB1Ne2IyEKjN4A1 Ks0BSkobOX2DC09rOx3SDm7rlM/e2CqT0HQUjszL5Zhm6vaNWKEuguCu1LxhxI6U8Kn8eZteb TmhUtOf3UMDCsbnjKOhxUFUdAoQolwEALbC0RD8TTU3dr9m7JNMjtr69uERQU2vLKvFP5C9GD gwAvpgdCQFfJjTYbhCTY8ENsXgPoHpfF51V6WEds1RQ1XmNDyX1vbSvTqC9Z1J3jpH6+c2HwK RI2Af63pt9U58hq1czgbnFT7/NiLegshp7PsELMvLiLbDItp/zjU33ubO/lbgOh85hHSyG3Fk WImu3GIFluDB/PRsfG2s9yBxcdHMRG3LrmrSfdVNBO8R4tLlQyFpiyLOCWU6mBhzGW5DO2KAX OR+KWh2SA1dFOM1rcvjUEFbCldhvwHbAjcvQLJ4Rpnk95pCKsxTvvOV1YUtokW43wG2ZJJs/O w9GF3n0WcobN0ZoIBUoUSET9mv7KPGnQFE+7gdU1yw2JyDpQ0lqwIwEzI+N31o6mYpAdlIPo/ xMTKUSIfXbNefnXecbFeVyGHxcSLhaMocdAbQI+KB+sphmOlBCTMDZQIURhTGTuKq+X/rTy0r /J9cLHP45LC7Db5g6wDWejCAh+fyvkE6oMJqUTiRUOM5cHVTp0de+zF2ykg= List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > Details: In function main(), the memory hold by variable > output_filename is > freed at line 329. It then tries to parse the next command option. > The freed > memory will be freed again at line 478 if a crafted option bypass the > memory > allocation at line 316. I think set output_filename to NULL after the > free > operation at line 329 will fix the issue. > ... I haven't had time yet to look into this, but to speed things up, would you have an example where the double free actually happens? Thanks. Michael --=20 Michael Meskes Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org) Meskes at (Debian|Postgresql) dot Org Jabber: michael at xmpp dot meskes dot org VfL Borussia! For=C3=A7a Bar=C3=A7a! SF 49ers! Use Debian GNU/Linux, Post= greSQL