Merge topic 'fix-libarchive-mktemp'

1f33b45d libarchive: Fix string concatentation in Windows mktemp implementation
This commit is contained in:
Brad King 2015-04-10 08:31:01 -04:00 committed by CMake Topic Stage
commit 8b4c40155a
1 changed files with 5 additions and 3 deletions

View File

@ -249,6 +249,8 @@ __archive_errx(int retvalue, const char *msg)
int int
__archive_mktemp(const char *tmpdir) __archive_mktemp(const char *tmpdir)
{ {
static const wchar_t *prefix = L"libarchive_";
static const wchar_t *suffix = L"XXXXXXXXXX";
static const wchar_t num[] = { static const wchar_t num[] = {
L'0', L'1', L'2', L'3', L'4', L'5', L'6', L'7', L'0', L'1', L'2', L'3', L'4', L'5', L'6', L'7',
L'8', L'9', L'A', L'B', L'C', L'D', L'E', L'F', L'8', L'9', L'A', L'B', L'C', L'D', L'E', L'F',
@ -323,10 +325,10 @@ __archive_mktemp(const char *tmpdir)
/* /*
* Create a temporary file. * Create a temporary file.
*/ */
archive_wstrcat(&temp_name, L"libarchive_"); archive_wstrcat(&temp_name, prefix);
xp = temp_name.s + archive_strlen(&temp_name); archive_wstrcat(&temp_name, suffix);
archive_wstrcat(&temp_name, L"XXXXXXXXXX");
ep = temp_name.s + archive_strlen(&temp_name); ep = temp_name.s + archive_strlen(&temp_name);
xp = ep - wcslen(suffix);
if (!CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, if (!CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL,
CRYPT_VERIFYCONTEXT)) { CRYPT_VERIFYCONTEXT)) {