BUG #15541: Use after release in PQprint

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: bianpan2016(at)163(dot)com
Subject: BUG #15541: Use after release in PQprint
Date: 2018-12-07 10:42:54
Message-ID: 15541-c835d8b9a903f7ad@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

The following bug has been logged on the website:

Bug reference: 15541
Logged by: Pan Bian
Email address: bianpan2016(at)163(dot)com
PostgreSQL version: 11.1
Operating system: Linux
Description:

File: src/interfaces/libpq/fe-print.c
Function: PQprint
Issue details:

The function PQprint releases the file hander fout via pclose or _pclose
when usePipe is true. After that, fout is used again to write message
"fputs("</table>\n", fout);".

For your convenience, I copy-and-paste related code as follows.

67 void
68 PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
69 {
...
310 if (usePipe)
311 {
312 #ifdef WIN32
313 _pclose(fout);
314 #else
315 pclose(fout);
316
317 #ifdef ENABLE_THREAD_SAFETY
318 /* we can't easily verify if EPIPE occurred, so say it did
*/
319 if (sigpipe_masked)
320 pq_reset_sigpipe(&osigset, sigpipe_pending, true);
321 #else
322 pqsignal(SIGPIPE, oldsigpipehandler);
323 #endif /* ENABLE_THREAD_SAFETY */
324 #endif /* WIN32 */
325 }
326 if (po->html3 && !po->expanded)
327 fputs("</table>\n", fout);
328 }
329 }

Thank you,
Pan Bian

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Jim Finnerty 2018-12-07 13:31:41 Re: BUG #15538: Postgres query performance is slow.
Previous Message PG Bug reporting form 2018-12-07 10:34:28 BUG #15540: Use after release in ExecuteTruncateGuts

Browse pgsql-hackers by date

  From Date Subject
Next Message Matsumura, Ryo 2018-12-07 10:54:49 RE: [PROPOSAL]a new data type 'bytea' for ECPG
Previous Message Magnus Hagander 2018-12-07 09:33:04 Re: Too many logs are written on Windows (LOG: could not reserve shared memory region (addr=%p) for child %p:)