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:
parent
2b7dbb8004
commit
293e0ea4cb
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user