fix: add quotes to all tar invocations via std::system (#909)

This commit is contained in:
Ruben Valls
2026-03-27 21:37:55 +01:00
committed by GitHub
parent 1a70f8c8a8
commit c7690c0e95
+4 -4
View File
@@ -3309,7 +3309,7 @@ remove_folder_and_subfolders(const std::string& folder)
# endif // !USE_SHELL_API
# else // !_WIN32
# if USE_SHELL_API
return std::system(("rm -R " + folder).c_str()) == EXIT_SUCCESS;
return std::system(("rm -R \"" + folder + "\"").c_str()) == EXIT_SUCCESS;
# else // !USE_SHELL_API
struct dir_deleter {
dir_deleter() {}
@@ -3375,7 +3375,7 @@ make_directory(const std::string& folder)
# endif // !USE_SHELL_API
# else // !_WIN32
# if USE_SHELL_API
return std::system(("mkdir -p " + folder).c_str()) == EXIT_SUCCESS;
return std::system(("mkdir -p \"" + folder + "\"").c_str()) == EXIT_SUCCESS;
# else // !USE_SHELL_API
return mkdir(folder.c_str(), 0777) == 0;
# endif // !USE_SHELL_API
@@ -3397,7 +3397,7 @@ delete_file(const std::string& file)
# endif // !USE_SHELL_API
# else // !_WIN32
# if USE_SHELL_API
return std::system(("rm " + file).c_str()) == EXIT_SUCCESS;
return std::system(("rm \"" + file + "\"").c_str()) == EXIT_SUCCESS;
# else // !USE_SHELL_API
return unlink(file.c_str()) == 0;
# endif // !USE_SHELL_API
@@ -3632,7 +3632,7 @@ bool
extract_gz_file(const std::string&, const std::string& gz_file, const std::string&)
{
# if USE_SHELL_API
bool unzipped = std::system(("tar -xzf " + gz_file + " -C " + get_install()).c_str()) == EXIT_SUCCESS;
bool unzipped = std::system(("tar -xzf \"" + gz_file + "\" -C \"" + get_install() + "\"").c_str()) == EXIT_SUCCESS;
# else // !USE_SHELL_API
const char prog[] = {"/usr/bin/tar"};
const char*const args[] =