summaryrefslogtreecommitdiff
path: root/archival/tar.c
diff options
context:
space:
mode:
authorEric Andersen2000-06-26 10:54:06 +0000
committerEric Andersen2000-06-26 10:54:06 +0000
commit3adffb7fc86ece4a9c8f550abf049a459f1ea1f6 (patch)
tree7cf083d19187362f06120705328ce2fa56b8a36f /archival/tar.c
parent10dc9d4d17e6880bfdfd253716ce72ec1243227f (diff)
downloadbusybox-3adffb7fc86ece4a9c8f550abf049a459f1ea1f6.zip
busybox-3adffb7fc86ece4a9c8f550abf049a459f1ea1f6.tar.gz
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
Diffstat (limited to 'archival/tar.c')
-rw-r--r--archival/tar.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/archival/tar.c b/archival/tar.c
index 1b783f0..836d127 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -824,12 +824,15 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
/* WARNING/NOTICE: I break Hard Links */
if (S_ISLNK(statbuf->st_mode)) {
+ int link_size=0;
char buffer[BUFSIZ];
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));
return ( FALSE);
}
+ buffer[link_size] = '\0';
strncpy(header.linkname, buffer, sizeof(header.linkname));
} else if (S_ISDIR(statbuf->st_mode)) {
header.typeflag = DIRTYPE;