]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Issue 378: compute string pointers after concatenation, to protect against reallocati...
authorTim Kientzle <kientzle@gmail.com>
Fri, 26 Sep 2014 01:51:57 +0000 (18:51 -0700)
committerTim Kientzle <kientzle@gmail.com>
Fri, 26 Sep 2014 01:51:57 +0000 (18:51 -0700)
libarchive/archive_util.c

index 1b685d109ddddb60d6ba516195537a0d66b356df..3a951c819afbe2c0ee80fa2346ae28c67ec204df 100644 (file)
@@ -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)) {