Skip to content

Commit

Permalink
fix: don't follow symlinks when removing junk files (transmission#1638)…
Browse files Browse the repository at this point in the history
… (transmission#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.
  • Loading branch information
Narthorn authored and ile6695 committed Jan 23, 2022
1 parent 2c69949 commit caef903
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libtransmission/torrent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2122,7 +2122,7 @@ static void removeEmptyFoldersAndJunkFiles(char const* folder)
auto const filename = tr_strvPath(folder, name);

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());
}
Expand Down

0 comments on commit caef903

Please sign in to comment.