Fix #95411: "//" temp directory prefix causing crash #118873

Closed
Campbell Barton wants to merge 3 commits from ideasman42:pr-temp-dir-sanitize into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
1 changed files with 10 additions and 0 deletions
Showing only changes of commit 958024b7c6 - Show all commits

View File

@ -8,6 +8,12 @@
#include "BLI_path_util.h"
#include "BLI_string.h"
#ifdef WIN32
# include "BLI_winstuff.h" /* For `W_OK`. */
#else
# include <unistd.h>
#endif
bool BLI_temp_directory_path_copy_if_valid(char *temp_directory,
const size_t buffer_size,
const char *dirpath)
@ -28,6 +34,10 @@ bool BLI_temp_directory_path_copy_if_valid(char *temp_directory,
if (!BLI_is_dir(dirpath)) {
return false;
}
/* Check the path is writable. */
if (BLI_access(dirpath, W_OK) != 0) {
return false;
}
BLI_strncpy(temp_directory, dirpath, buffer_size);