1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-30 11:36:07 +00:00

fix: don't follow symlinks when removing junk files (#1638) (#1638)

This prevents accidentally following a symlink that points outside of
the torrent's folder and crawling the rest of the drive for junk files
to remove.

This also prevents symlinks that point to a folder from being treated as
real directories, which would cause them to be removed even if the folder
they point to is not actually empty.
This commit is contained in:
Vincent Vinel 2022-01-21 18:53:00 +01:00 committed by GitHub
parent 9e5e27adb6
commit ddca909699
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2122,7 +2122,7 @@ static void removeEmptyFoldersAndJunkFiles(char const* folder)
auto const filename = tr_strvPath(folder, name); auto const filename = tr_strvPath(folder, name);
auto info = tr_sys_path_info{}; auto info = tr_sys_path_info{};
if (tr_sys_path_get_info(filename.c_str(), 0, &info, nullptr) && info.type == TR_SYS_PATH_IS_DIRECTORY) if (tr_sys_path_get_info(filename.c_str(), TR_SYS_PATH_NO_FOLLOW, &info, nullptr) && info.type == TR_SYS_PATH_IS_DIRECTORY)
{ {
removeEmptyFoldersAndJunkFiles(filename.c_str()); removeEmptyFoldersAndJunkFiles(filename.c_str());
} }