diff options
Diffstat (limited to 'tar.c')
-rw-r--r-- | tar.c | 12 |
1 files changed, 3 insertions, 9 deletions
@@ -921,16 +921,10 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *header_name, | |||
921 | header.typeflag = LNKTYPE; | 921 | header.typeflag = LNKTYPE; |
922 | strncpy(header.linkname, tbInfo->hlInfo->name, sizeof(header.linkname)); | 922 | strncpy(header.linkname, tbInfo->hlInfo->name, sizeof(header.linkname)); |
923 | } else if (S_ISLNK(statbuf->st_mode)) { | 923 | } else if (S_ISLNK(statbuf->st_mode)) { |
924 | int link_size=0; | 924 | char *lpath = xreadlink(real_name); |
925 | char buffer[BUFSIZ]; | ||
926 | header.typeflag = SYMTYPE; | 925 | header.typeflag = SYMTYPE; |
927 | link_size = readlink(real_name, buffer, sizeof(buffer) - 1); | 926 | strncpy(header.linkname, lpath, sizeof(header.linkname)); |
928 | if ( link_size < 0) { | 927 | free(lpath); |
929 | perror_msg("Error reading symlink '%s'", header.name); | ||
930 | return ( FALSE); | ||
931 | } | ||
932 | buffer[link_size] = '\0'; | ||
933 | strncpy(header.linkname, buffer, sizeof(header.linkname)); | ||
934 | } else if (S_ISDIR(statbuf->st_mode)) { | 928 | } else if (S_ISDIR(statbuf->st_mode)) { |
935 | header.typeflag = DIRTYPE; | 929 | header.typeflag = DIRTYPE; |
936 | strncat(header.name, "/", sizeof(header.name)); | 930 | strncat(header.name, "/", sizeof(header.name)); |