MFV r321673:

Sync libarchive with vendor.

Relevant vendor changes:
  PR #926: ensure ar strtab is null terminated

MFC after:	1 week
This commit is contained in:
mm 2017-07-28 23:56:07 +00:00
parent 2b7dbb8004
commit 293e0ea4cb
2 changed files with 4 additions and 3 deletions

View File

@ -64,7 +64,7 @@ typedef struct {
} archive_crypto_ctx;
#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H)
#include <Bcrypt.h>
#include <bcrypt.h>
/* Common in other bcrypt implementations, but missing from VS2008. */
#ifndef BCRYPT_SUCCESS

View File

@ -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;
}