From: Tim Kientzle Date: Fri, 26 Sep 2014 01:51:57 +0000 (-0700) Subject: Issue 378: compute string pointers after concatenation, to protect against reallocati... X-Git-Tag: v3.1.900a~200 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1732828cd802c26e18891c4c95f49c15819c985;p=thirdparty%2Flibarchive.git Issue 378: compute string pointers after concatenation, to protect against reallocation moving the string --- diff --git a/libarchive/archive_util.c b/libarchive/archive_util.c index 1b685d109..3a951c819 100644 --- a/libarchive/archive_util.c +++ b/libarchive/archive_util.c @@ -330,10 +330,11 @@ __archive_mktemp(const char *tmpdir) /* * Create a temporary file. */ + const wchar_t *suffix = L"XXXXXXXXXX"; archive_wstrcat(&temp_name, L"libarchive_"); - xp = temp_name.s + archive_strlen(&temp_name); - archive_wstrcat(&temp_name, L"XXXXXXXXXX"); + archive_wstrcat(&temp_name, suffix); ep = temp_name.s + archive_strlen(&temp_name); + xp = ep - wcslen(suffix); if (!CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {