pgsql: Fix portability and safety issues in pqTraceFormatTimestamp.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix portability and safety issues in pqTraceFormatTimestamp.
Date: 2021-03-31 21:04:00
Message-ID: E1lRi0O-0003vA-Df@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix portability and safety issues in pqTraceFormatTimestamp.

Remove confusion between time_t and pg_time_t; neither
gettimeofday() nor localtime() deal in the latter.
libpq indeed has no business using <pgtime.h> at all.

Use snprintf not sprintf, to ensure we can't overrun the
supplied buffer. (Unlikely, but let's be safe.)

Per buildfarm.

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f1be740a991406d7885047beb971e1ff5dbe8b71

Modified Files
--------------
src/interfaces/libpq/fe-trace.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2021-03-31 21:14:38 pgsql: Fix unportable use of isprint().
Previous Message Tom Lane 2021-03-31 20:45:33 pgsql: Don't prematurely cram a value into a short int.