aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2000-06-26 10:54:06 +0000
committerEric Andersen <andersen@codepoet.org>2000-06-26 10:54:06 +0000
commit3adffb7fc86ece4a9c8f550abf049a459f1ea1f6 (patch)
tree7cf083d19187362f06120705328ce2fa56b8a36f
parent10dc9d4d17e6880bfdfd253716ce72ec1243227f (diff)
downloadbusybox-w32-3adffb7fc86ece4a9c8f550abf049a459f1ea1f6.tar.gz
busybox-w32-3adffb7fc86ece4a9c8f550abf049a459f1ea1f6.tar.bz2
busybox-w32-3adffb7fc86ece4a9c8f550abf049a459f1ea1f6.zip
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
-rw-r--r--archival/tar.c5
-rw-r--r--tar.c5
2 files changed, 8 insertions, 2 deletions
diff --git a/archival/tar.c b/archival/tar.c
index 1b783f0f5..836d127e7 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -824,12 +824,15 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
824 824
825 /* WARNING/NOTICE: I break Hard Links */ 825 /* WARNING/NOTICE: I break Hard Links */
826 if (S_ISLNK(statbuf->st_mode)) { 826 if (S_ISLNK(statbuf->st_mode)) {
827 int link_size=0;
827 char buffer[BUFSIZ]; 828 char buffer[BUFSIZ];
828 header.typeflag = SYMTYPE; 829 header.typeflag = SYMTYPE;
829 if ( readlink(fileName, buffer, sizeof(buffer) - 1) < 0) { 830 link_size = readlink(fileName, buffer, sizeof(buffer) - 1);
831 if ( link_size < 0) {
830 errorMsg("Error reading symlink '%s': %s\n", header.name, strerror(errno)); 832 errorMsg("Error reading symlink '%s': %s\n", header.name, strerror(errno));
831 return ( FALSE); 833 return ( FALSE);
832 } 834 }
835 buffer[link_size] = '\0';
833 strncpy(header.linkname, buffer, sizeof(header.linkname)); 836 strncpy(header.linkname, buffer, sizeof(header.linkname));
834 } else if (S_ISDIR(statbuf->st_mode)) { 837 } else if (S_ISDIR(statbuf->st_mode)) {
835 header.typeflag = DIRTYPE; 838 header.typeflag = DIRTYPE;
diff --git a/tar.c b/tar.c
index 1b783f0f5..836d127e7 100644
--- a/tar.c
+++ b/tar.c
@@ -824,12 +824,15 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
824 824
825 /* WARNING/NOTICE: I break Hard Links */ 825 /* WARNING/NOTICE: I break Hard Links */
826 if (S_ISLNK(statbuf->st_mode)) { 826 if (S_ISLNK(statbuf->st_mode)) {
827 int link_size=0;
827 char buffer[BUFSIZ]; 828 char buffer[BUFSIZ];
828 header.typeflag = SYMTYPE; 829 header.typeflag = SYMTYPE;
829 if ( readlink(fileName, buffer, sizeof(buffer) - 1) < 0) { 830 link_size = readlink(fileName, buffer, sizeof(buffer) - 1);
831 if ( link_size < 0) {
830 errorMsg("Error reading symlink '%s': %s\n", header.name, strerror(errno)); 832 errorMsg("Error reading symlink '%s': %s\n", header.name, strerror(errno));
831 return ( FALSE); 833 return ( FALSE);
832 } 834 }
835 buffer[link_size] = '\0';
833 strncpy(header.linkname, buffer, sizeof(header.linkname)); 836 strncpy(header.linkname, buffer, sizeof(header.linkname));
834 } else if (S_ISDIR(statbuf->st_mode)) { 837 } else if (S_ISDIR(statbuf->st_mode)) {
835 header.typeflag = DIRTYPE; 838 header.typeflag = DIRTYPE;