Re: Use after free? in fe-connect.c:closePGconn - Mailing list pgsql-bugs

From Ranier VF
Subject Re: Use after free? in fe-connect.c:closePGconn
Date
Msg-id BLU183-W9C732F0EE44D74D3B634AE3560@phx.gbl
Whole thread Raw
In response to Re: Use after free? in fe-connect.c:closePGconn  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
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 <ranier_gyn@hotmail.com> 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

                           =

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #13907: Restore materialized view throw permission denied
Next
From: Martín Marqués
Date:
Subject: pg_dump doesn't dump new objects created in schemas from extensions