Skip to content

Commit 5d923eb

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 0dcf68e commit 5d923eb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/bin/pg_waldump/compat.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ timestamptz_to_str(TimestampTz dt)
5858
strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S", ltime);
5959
strftime(zone, sizeof(zone), "%Z", ltime);
6060

61-
sprintf(buf, "%s.%06d %s", ts, (int) (dt % USECS_PER_SEC), zone);
61+
snprintf(buf, sizeof(buf), "%s.%06d %s",
62+
ts, (int) (dt % USECS_PER_SEC), zone);
6263

6364
return buf;
6465
}

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