Skip to content

Commit a6fc328

Browse files
committed
Use InstDir’s parent as target in ChangeDirectoryToSafeDirectory
At script termination, it is more likely that the process has search (execute) permission on InstDir’s parent directory than on the directory containing the SFX file.
1 parent e038a2e commit a6fc328

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/inst_dir.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,18 @@ bool ChangeDirectoryToScriptDirectory(void)
209209
// Moves the application to a safe directory.
210210
bool ChangeDirectoryToSafeDirectory(void)
211211
{
212+
if (!IsInstDirSet()) {
213+
APP_ERROR("Installation directory has not been set");
214+
return false;
215+
}
216+
212217
bool changed = false;
213218
char *working_dir = NULL;
214219

215-
working_dir = GetTempDirectoryPath();
220+
working_dir = GetParentPath(InstDir);
216221
if (!working_dir) {
217-
APP_ERROR("GetTempDirectoryPath failed");
218-
222+
APP_ERROR("Failed to get parent path");
223+
219224
goto cleanup;
220225
}
221226

@@ -224,7 +229,7 @@ bool ChangeDirectoryToSafeDirectory(void)
224229
goto cleanup;
225230
}
226231

227-
DEBUG("Failed to change to temporary directory. Trying fallback directory");
232+
DEBUG("Failed to change to safe directory. Trying fallback directory");
228233

229234
changed = ChangeWorkingDirectory(FALLBACK_DIRECTORY_PATH);
230235
if (!changed) {

0 commit comments

Comments
 (0)