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

Commit4318118

Browse files
committed
Truncate strings in tarCreateHeader() with strlcpy(), not sprintf().
This supplements the GNU libc bug #6530 workarounds introduced in commit54cd4f0. On affected systems, atar-format pg_basebackup failed when some filename beneath the datadirectory was not valid character data in the postmaster/walsenderlocale. Back-patch to 9.1, where pg_basebackup was introduced. Extant,bug-prone conversion specifications receive only ASCII bytes or involvelow-importance messages.
1 parentad89a5d commit4318118

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

‎src/bin/pg_basebackup/t/010_pg_basebackup.pl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717
['pg_basebackup','-D',"$tempdir/backup" ],
1818
'pg_basebackup fails because of hba');
1919

20+
# Some Windows ANSI code pages may reject this filename, in which case we
21+
# quietly proceed without this bit of test coverage.
22+
if (open BADCHARS,">>$tempdir/pgdata/FOO\xe0\xe0\xe0BAR")
23+
{
24+
print BADCHARS"test backup of file with non-UTF8 name\n";
25+
close BADCHARS;
26+
}
27+
2028
open HBA,">>$tempdir/pgdata/pg_hba.conf";
2129
print HBA"local replication all trust\n";
2230
print HBA"host replication all 127.0.0.1/32 trust\n";

‎src/port/tar.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ tarCreateHeader(char *h, const char *filename, const char *linktarget,
6868
memset(h,0,512);/* assume tar header size */
6969

7070
/* Name 100 */
71-
sprintf(&h[0],"%.99s",filename);
71+
strlcpy(&h[0],filename,100);
7272
if (linktarget!=NULL||S_ISDIR(mode))
7373
{
7474
/*
@@ -110,7 +110,7 @@ tarCreateHeader(char *h, const char *filename, const char *linktarget,
110110
/* Type - Symbolic link */
111111
sprintf(&h[156],"2");
112112
/* Link Name 100 */
113-
sprintf(&h[157],"%.99s",linktarget);
113+
strlcpy(&h[157],linktarget,100);
114114
}
115115
elseif (S_ISDIR(mode))
116116
/* Type - directory */
@@ -127,11 +127,11 @@ tarCreateHeader(char *h, const char *filename, const char *linktarget,
127127

128128
/* User 32 */
129129
/* XXX: Do we need to care about setting correct username? */
130-
sprintf(&h[265],"%.31s","postgres");
130+
strlcpy(&h[265],"postgres",32);
131131

132132
/* Group 32 */
133133
/* XXX: Do we need to care about setting correct group name? */
134-
sprintf(&h[297],"%.31s","postgres");
134+
strlcpy(&h[297],"postgres",32);
135135

136136
/* Major Dev 8 */
137137
sprintf(&h[329],"%07o ",0);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp