From ddca909699eb838044753362a7e41b5bc65afe02 Mon Sep 17 00:00:00 2001 From: Vincent Vinel Date: Fri, 21 Jan 2022 18:53:00 +0100 Subject: [PATCH] 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. --- libtransmission/torrent.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libtransmission/torrent.cc b/libtransmission/torrent.cc index 281b0254a..a66f07af5 100644 --- a/libtransmission/torrent.cc +++ b/libtransmission/torrent.cc @@ -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()); }