mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-29 00:10:02 -05:00
fix: Added protection against deleting symlinks (#2288)
This PR improves the safety and reliability of the deleteOldFiles() function by: Preventing symlink attacks Uses std::filesystem::canonical() to resolve all paths, eliminating ./.. and symlinks Verifies each file is actually inside the target directory before deletion Safer file operations Explicitly skips non-regular files (directories/symlinks) --------- Co-authored-by: Nik <werwolv98@gmail.com>
This commit is contained in:
@@ -138,7 +138,8 @@ namespace hex {
|
||||
// Add plugin library folders to dll search path
|
||||
for (const auto &path : paths::Libraries.read()) {
|
||||
if (std::fs::exists(path))
|
||||
setenv("LD_LIBRARY_PATH", fmt::format("{};{}", hex::getEnvironmentVariable("LD_LIBRARY_PATH").value_or(""), path.string().c_str()).c_str(), true);
|
||||
|
||||
setenv("LD_LIBRARY_PATH", fmt::format("{}:{}", hex::getEnvironmentVariable("LD_LIBRARY_PATH").value_or(""), path.string().c_str()).c_str(), true);
|
||||
}
|
||||
|
||||
// Redirect stdout to log file if we're not running in a terminal
|
||||
|
||||
Reference in New Issue
Block a user