summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 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;
diff --git a/tar.c b/tar.c
index 1b783f0..836d127 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;