From f9dacbfb50d0d47ce999bd24a03e095772e676e1 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Fri, 21 Jul 2017 06:46:17 -0400 Subject: [PATCH] ensure ar strtab is null terminated ar support calls strstr() on the strtab, which requres that its arguments are null terminated. --- libarchive/archive_write_set_format_ar.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libarchive/archive_write_set_format_ar.c b/libarchive/archive_write_set_format_ar.c index c9771d81a..6fab9d669 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); + ar->strtab[s] = '\0'; ar->has_strtab = 1; } -- 2.47.2