From: Ed Maste Date: Fri, 21 Jul 2017 10:46:17 +0000 (-0400) Subject: ensure ar strtab is null terminated X-Git-Tag: v3.3.3~51^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f9dacbfb50d0d47ce999bd24a03e095772e676e1;p=thirdparty%2Flibarchive.git ensure ar strtab is null terminated ar support calls strstr() on the strtab, which requres that its arguments are null terminated. --- 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; }