vcl/source/filter/ieps/ieps.cxx |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

New commits:
commit d3742c3869b81068d01fd836018615bbfb38e2cc
Author:     Caolán McNamara <[email protected]>
AuthorDate: Tue Jul 9 13:08:23 2024 +0100
Commit:     Michael Stahl <[email protected]>
CommitDate: Tue Aug 20 12:09:37 2024 +0200

    use a throwaway TMPDIR for ghostscript-using helpers
    
    Change-Id: Iba5a475399589c9e2c4fd485d613f0dedfe0dc44
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170124
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <[email protected]>
    (cherry picked from commit b0230fbd68924916ffad47958e0ca87bb532d7e3)

diff --git a/vcl/source/filter/ieps/ieps.cxx b/vcl/source/filter/ieps/ieps.cxx
index 9c223d6cda90..936e25c15fb5 100644
--- a/vcl/source/filter/ieps/ieps.cxx
+++ b/vcl/source/filter/ieps/ieps.cxx
@@ -152,6 +152,14 @@ static oslProcessError runProcessWithPathSearch(const 
OUString &rProgName,
     rtl_uString* pArgs[], sal_uInt32 nArgs, oslProcess *pProcess,
     oslFileHandle *pIn, oslFileHandle *pOut, oslFileHandle *pErr)
 {
+    // run things that directly or indirectly might call gs in a tmpdir of 
their own
+    utl::TempFile aTMPDirectory(nullptr, true);
+    aTMPDirectory.EnableKillingFile(true);
+    OUString sTmpDirEnv = "TMPDIR=" + aTMPDirectory.GetFileName();
+
+    rtl_uString* ustrEnvironment[1];
+    ustrEnvironment[0] = sTmpDirEnv.pData;
+
     oslProcessError result = osl_Process_E_None;
     oslSecurity pSecurity = osl_getCurrentSecurity();
 #ifdef _WIN32
@@ -179,11 +187,11 @@ static oslProcessError runProcessWithPathSearch(const 
OUString &rProgName,
     else
         result = osl_executeProcess_WithRedirectedIO(url.pData,
             pArgs, nArgs, osl_Process_HIDDEN,
-            pSecurity, nullptr, nullptr, 0, pProcess, pIn, pOut, pErr);
+            pSecurity, nullptr, ustrEnvironment, 1, pProcess, pIn, pOut, pErr);
 #else
     result = osl_executeProcess_WithRedirectedIO(rProgName.pData,
         pArgs, nArgs, osl_Process_SEARCHPATH | osl_Process_HIDDEN,
-        pSecurity, nullptr, nullptr, 0, pProcess, pIn, pOut, pErr);
+        pSecurity, nullptr, ustrEnvironment, 1, pProcess, pIn, pOut, pErr);
 #endif
     osl_freeSecurityHandle( pSecurity );
     return result;

Reply via email to