From adabb70c1a20ff6c0d1e9dd6e4eee7b321334345 Mon Sep 17 00:00:00 2001 From: andersen Date: Mon, 26 Jun 2000 10:54:06 +0000 Subject: 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 git-svn-id: svn://busybox.net/trunk/busybox@702 69ca8d6d-28ef-0310-b511-8ec308f3f277 --- tar.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tar.c') 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 /* 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; -- cgit v1.2.3-55-g6feb