summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2023-04-30 03:38:07 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2023-04-30 03:38:07 (EDT)
commitc28ea1e0a30ad036a30288c8cda68c80c08ab0ec (patch)
treee66b48478bb8d78aafbe8a2fb6585f9c7c54f0e7
parentd159b5cf03212e9ecb848dd7eef5edc3ba1a7bba (diff)
uname: Fix written linkname
-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;