summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ustar.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/ustar.c b/src/ustar.c
index e1771c3..f14a3d4 100644
--- a/src/ustar.c
+++ b/src/ustar.c
@@ -308,9 +308,14 @@ opkg_opk_ustar_write_header(struct opkg_opk_ustar *ustar,
default:
return OPKG_OPK_ERROR; /* Unsupported */
}
- linkname_len = strlen(linkname);
- memcpy(ustar->header.linkname, linkname, linkname_len);
- ustar->header.linkname[linkname_len] = '\0';
+ if (*ustar->header.typeflag == '2') {
+ linkname_len = strlen(linkname);
+ memcpy(ustar->header.linkname, linkname, linkname_len);
+ } else {
+ linkname_len = 0;
+ }
+ memset(ustar->header.linkname, 0,
+ sizeof(ustar->header.linkname) - linkname_len);
if (opkg_opk_gzip_write(ustar->gzip, &ustar->header,
OPKG_OPK_USTAR_RECORD_SIZE, 0) != OPKG_OPK_OK) {
return OPKG_OPK_ERROR;