Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bDb0Y-0001Kk-Ic for pgsql-bugs@arkaria.postgresql.org; Thu, 16 Jun 2016 17:23:10 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bDb0Y-0002w2-5P for pgsql-bugs@arkaria.postgresql.org; Thu, 16 Jun 2016 17:23: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_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bDa8B-00061G-LG for pgsql-bugs@postgresql.org; Thu, 16 Jun 2016 16:26:59 +0000 Received: from blu004-omc2s15.hotmail.com ([65.55.111.90]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bDa82-0003wj-T4 for pgsql-bugs@postgresql.org; Thu, 16 Jun 2016 16:26:59 +0000 Received: from BLU183-W9 ([65.55.111.71]) by BLU004-OMC2S15.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Thu, 16 Jun 2016 09:26:48 -0700 X-TMN: [79o+XxiPR2rfYYM7ckaEkofgnaiBfXMc] X-Originating-Email: [ranier_gyn@hotmail.com] Message-ID: Content-Type: multipart/alternative; boundary="_cf812482-6fc7-478b-a481-e1bf50024dfb_" From: Ranier VF To: Tom Lane CC: "pgsql-bugs@postgresql.org" Subject: Re: Use after free? in fe-connect.c:closePGconn Date: Thu, 16 Jun 2016 16:26:48 +0000 Importance: Normal In-Reply-To: <15516.1466031953@sss.pgh.pa.us> References: ,<15516.1466031953@sss.pgh.pa.us> MIME-Version: 1.0 X-OriginalArrivalTime: 16 Jun 2016 16:26:48.0922 (UTC) FILETIME=[E1C103A0:01D1C7EB] X-Pg-Spam-Score: -4.0 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org --_cf812482-6fc7-478b-a481-e1bf50024dfb_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi Tom=2C > All the callers do=2C so I don't entirely see your point. Well=2C I still confuse... > The stack traces you show look to me like the fault is probably in > the caller=2C ie=2C calling PQfinish twice on the same "conn". patch from dbd_pgsql_close function: 275 if (dbd->conn !=3D NULL) { 276 #if defined(DEBUG) && !defined(_WIN32) 277 PQuntrace(dbd->conn)=3B 278 #endif 279 PQfinish(dbd->conn)=3B 280 dbd->conn =3D NULL=3B 281 } 282 FREE(dbd)=3B 283 dbd =3D NULL=3B IHMO=2C the caller of PQfinish can=B4t call twice. Best regards=2C Ranier > From: tgl@sss.pgh.pa.us > To: ranier_gyn@hotmail.com > CC: pgsql-bugs@postgresql.org > Subject: Re: [BUGS] Use after free? in fe-connect.c:closePGconn > Date: Wed=2C 15 Jun 2016 19:05:53 -0400 >=20 > Ranier VF writes: > > In [d:\pginstaller.auto\postgres.windows\src\interfaces\libpq\fe-conne= ct.c=2C > > closePGconn(PGconn *conn): > > Does not check if conn is NULL. >=20 > All the callers do=2C so I don't entirely see your point. >=20 > The stack traces you show look to me like the fault is probably in > the caller=2C ie=2C calling PQfinish twice on the same "conn". >=20 > regards=2C tom lane =20 =09 =20 Livre de v=EDrus. www.avast.com. =09 =09 = --_cf812482-6fc7-478b-a481-e1bf50024dfb_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi Tom=2C

>=3B All the = callers do=2C so I don't entirely see your point.
Well=2C I still confus= e...

>=3B The stack traces you show look to me like the fault is p= robably in
>=3B the caller=2C ie=2C calling PQfinish twice on the same= "conn".
patch from dbd_pgsql_close function:
275  =3B =3B&nb= sp=3B =3B =3B if (dbd->=3Bconn !=3D NULL) {
276  =3B = =3B =3B =3B =3B =3B =3B =3B #if defined(DEBUG) &= =3B&=3B !defined(_WIN32)
277  =3B =3B =3B =3B =3B=  =3B =3B =3B PQuntrace(dbd->=3Bconn)=3B
278  =3B = =3B =3B =3B =3B =3B =3B =3B #endif
279  =3B&= nbsp=3B =3B =3B =3B =3B =3B =3B PQfinish(dbd->=3B= conn)=3B
280  =3B =3B =3B =3B =3B =3B =3B&nb= sp=3B dbd->=3Bconn =3D NULL=3B
281  =3B =3B =3B =3B&nb= sp=3B }
282  =3B =3B =3B =3B =3B FREE(dbd)=3B
283=  =3B =3B =3B =3B =3B dbd =3D NULL=3B

IHMO=2C th= e caller of PQfinish can=B4t call twice.

Best regards=2C

Rani= er

>=3B From: tgl@sss.pgh.pa.us
>=3B To: ranier_gyn@hotm= ail.com
>=3B CC: pgsql-bugs@postgresql.org
>=3B Subject: Re: [BUG= S] Use after free? in fe-connect.c:closePGconn
>=3B Date: Wed=2C 15 Ju= n 2016 19:05:53 -0400
>=3B
>=3B Ranier VF <=3Branier_gyn@hotma= il.com>=3B writes:
>=3B >=3B In [d:\pginstaller.auto\postgres.win= dows\src\interfaces\libpq\fe-connect.c=2C
>=3B >=3B closePGconn(PGco= nn *conn):
>=3B >=3B Does not check if conn is NULL.
>=3B
&= gt=3B All the callers do=2C so I don't entirely see your point.
>=3B <= br>>=3B The stack traces you show look to me like the fault is probably i= n
>=3B the caller=2C ie=2C calling PQfinish twice on the same "conn".<= br>>=3B
>=3B regards=2C tom lane

Livre de v=EDrus. www.avast.com.
=
= --_cf812482-6fc7-478b-a481-e1bf50024dfb_--