readlink(2) does not NULL terminate the buffer it reads in, but tar expected it
to do so. This caused symlinks stored in tarballs to likely have trailing crap in the stored symlink named. Oops. -Erik
This commit is contained in:
parent
10dc9d4d17
commit
3adffb7fc8
@ -824,12 +824,15 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
|
|||||||
|
|
||||||
/* WARNING/NOTICE: I break Hard Links */
|
/* WARNING/NOTICE: I break Hard Links */
|
||||||
if (S_ISLNK(statbuf->st_mode)) {
|
if (S_ISLNK(statbuf->st_mode)) {
|
||||||
|
int link_size=0;
|
||||||
char buffer[BUFSIZ];
|
char buffer[BUFSIZ];
|
||||||
header.typeflag = SYMTYPE;
|
header.typeflag = SYMTYPE;
|
||||||
if ( readlink(fileName, buffer, sizeof(buffer) - 1) < 0) {
|
link_size = readlink(fileName, buffer, sizeof(buffer) - 1);
|
||||||
|
if ( link_size < 0) {
|
||||||
errorMsg("Error reading symlink '%s': %s\n", header.name, strerror(errno));
|
errorMsg("Error reading symlink '%s': %s\n", header.name, strerror(errno));
|
||||||
return ( FALSE);
|
return ( FALSE);
|
||||||
}
|
}
|
||||||
|
buffer[link_size] = '\0';
|
||||||
strncpy(header.linkname, buffer, sizeof(header.linkname));
|
strncpy(header.linkname, buffer, sizeof(header.linkname));
|
||||||
} else if (S_ISDIR(statbuf->st_mode)) {
|
} else if (S_ISDIR(statbuf->st_mode)) {
|
||||||
header.typeflag = DIRTYPE;
|
header.typeflag = DIRTYPE;
|
||||||
|
5
tar.c
5
tar.c
@ -824,12 +824,15 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
|
|||||||
|
|
||||||
/* WARNING/NOTICE: I break Hard Links */
|
/* WARNING/NOTICE: I break Hard Links */
|
||||||
if (S_ISLNK(statbuf->st_mode)) {
|
if (S_ISLNK(statbuf->st_mode)) {
|
||||||
|
int link_size=0;
|
||||||
char buffer[BUFSIZ];
|
char buffer[BUFSIZ];
|
||||||
header.typeflag = SYMTYPE;
|
header.typeflag = SYMTYPE;
|
||||||
if ( readlink(fileName, buffer, sizeof(buffer) - 1) < 0) {
|
link_size = readlink(fileName, buffer, sizeof(buffer) - 1);
|
||||||
|
if ( link_size < 0) {
|
||||||
errorMsg("Error reading symlink '%s': %s\n", header.name, strerror(errno));
|
errorMsg("Error reading symlink '%s': %s\n", header.name, strerror(errno));
|
||||||
return ( FALSE);
|
return ( FALSE);
|
||||||
}
|
}
|
||||||
|
buffer[link_size] = '\0';
|
||||||
strncpy(header.linkname, buffer, sizeof(header.linkname));
|
strncpy(header.linkname, buffer, sizeof(header.linkname));
|
||||||
} else if (S_ISDIR(statbuf->st_mode)) {
|
} else if (S_ISDIR(statbuf->st_mode)) {
|
||||||
header.typeflag = DIRTYPE;
|
header.typeflag = DIRTYPE;
|
||||||
|
Loading…
Reference in New Issue
Block a user