Skip to content

Commit 8870e29

Browse files
committed
Use snprintf not sprintf in pg_waldump's timestamptz_to_str.
This could only cause an issue if strftime returned a ridiculously long timezone name, which seems unlikely; and it wouldn't qualify as a security problem even then, since pg_waldump (nee pg_xlogdump) is a debug tool not part of the server. But gcc 8 has started issuing warnings about it, so let's use snprintf and be safe. Backpatch to 9.3 where this code was added. Discussion: https://postgr.es/m/21789.1529170195@sss.pgh.pa.us
1 parent e951f66 commit 8870e29

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/bin/pg_xlogdump/compat.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@ timestamptz_to_str(TimestampTz dt)
6464
strftime(zone, sizeof(zone), "%Z", ltime);
6565

6666
#ifdef HAVE_INT64_TIMESTAMP
67-
sprintf(buf, "%s.%06d %s", ts, (int) (dt % USECS_PER_SEC), zone);
67+
snprintf(buf, sizeof(buf),
68+
"%s.%06d %s", ts, (int) (dt % USECS_PER_SEC), zone);
6869
#else
69-
sprintf(buf, "%s.%.6f %s", ts, fabs(dt - floor(dt)), zone);
70+
snprintf(buf, sizeof(buf),
71+
"%s.%.6f %s", ts, fabs(dt - floor(dt)), zone);
7072
#endif
7173

7274
return buf;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy