Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8870e29

Browse files
committed
Use snprintf not sprintf in pg_waldump's timestamptz_to_str.
This could only cause an issue if strftime returned a ridiculouslylong timezone name, which seems unlikely; and it wouldn't qualifyas 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 issuingwarnings 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 parente951f66 commit8870e29

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
#ifdefHAVE_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
returnbuf;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp