aboutsummaryrefslogtreecommitdiffstats
path: root/libarchive/archive_write_set_format_ar.c
diff options
context:
space:
mode:
Diffstat (limited to 'libarchive/archive_write_set_format_ar.c')
-rw-r--r--libarchive/archive_write_set_format_ar.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libarchive/archive_write_set_format_ar.c b/libarchive/archive_write_set_format_ar.c
index c9771d81a128..441119d5d714 100644
--- a/libarchive/archive_write_set_format_ar.c
+++ b/libarchive/archive_write_set_format_ar.c
@@ -374,13 +374,14 @@ archive_write_ar_data(struct archive_write *a, const void *buff, size_t s)
return (ARCHIVE_WARN);
}
- ar->strtab = (char *)malloc(s);
+ ar->strtab = (char *)malloc(s + 1);
if (ar->strtab == NULL) {
archive_set_error(&a->archive, ENOMEM,
"Can't allocate strtab buffer");
return (ARCHIVE_FATAL);
}
- strncpy(ar->strtab, buff, s);
+ memcpy(ar->strtab, buff, s);
+ ar->strtab[s] = '\0';
ar->has_strtab = 1;
}