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

Commit45a1d77

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 parent2031931 commit45a1d77

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎src/port/tar.c

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

6464
/* Name 100 */
65-
sprintf(&h[0],"%.99s",filename);
65+
strlcpy(&h[0],filename,100);
6666
if (linktarget!=NULL||S_ISDIR(mode))
6767
{
6868
/*
@@ -104,7 +104,7 @@ tarCreateHeader(char *h, const char *filename, const char *linktarget,
104104
/* Type - Symbolic link */
105105
sprintf(&h[156],"2");
106106
/* Link Name 100 */
107-
sprintf(&h[157],"%.99s",linktarget);
107+
strlcpy(&h[157],linktarget,100);
108108
}
109109
elseif (S_ISDIR(mode))
110110
/* Type - directory */
@@ -121,11 +121,11 @@ tarCreateHeader(char *h, const char *filename, const char *linktarget,
121121

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

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

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp