summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2023-04-25 05:35:44 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2023-04-25 05:45:27 (EDT)
commit28ea2b9718162761b5de617efa74ae2bd020acb2 (patch)
treedb06f233d3e6a3c832f79a84274a12e0ac9d09b6 /src
parent2701327cbb9d29e6cd7121fbd1ffee96588aa70b (diff)
ustar: Ensure listed linkname is NUL-terminated
Also simplify uname and gname copying.
Diffstat (limited to 'src')
-rw-r--r--src/ustar.c10
-rw-r--r--src/ustar.h2
2 files changed, 6 insertions, 6 deletions
diff --git a/src/ustar.c b/src/ustar.c
index 749af02..c759781 100644
--- a/src/ustar.c
+++ b/src/ustar.c
@@ -201,7 +201,9 @@ opkg_opk_ustar_list(struct opkg_opk_ustar *ustar,
case '2': /* Symbolic link */
(*member)->type = 'l';
strncpy((*member)->linkname, ustar->header.linkname,
- sizeof((*member)->linkname));
+ sizeof(ustar->header.linkname));
+ (*member)->linkname[sizeof((*member)->linkname) - 1] =
+ '\0';
break;
case '3': /* Character special file */
(*member)->type = 'c';
@@ -220,10 +222,8 @@ opkg_opk_ustar_list(struct opkg_opk_ustar *ustar,
free(*member);
return OPKG_OPK_ERROR; /* Unsupported */
}
- strncpy((*member)->uname, ustar->header.uname,
- sizeof((*member)->uname));
- strncpy((*member)->gname, ustar->header.gname,
- sizeof((*member)->gname));
+ strcpy((*member)->uname, ustar->header.uname);
+ strcpy((*member)->gname, ustar->header.gname);
/* Seek through data records until next header record. */
while (ustar->data_size_remaining > 0) {
diff --git a/src/ustar.h b/src/ustar.h
index 3495d38..220603a 100644
--- a/src/ustar.h
+++ b/src/ustar.h
@@ -35,7 +35,7 @@ struct opkg_opk_ustar_member {
uint64_t size;
int64_t mtime;
char type;
- char linkname[100];
+ char linkname[101];
char uname [32];
char gname [32];
struct opkg_opk_ustar_member *next;