fixed potential security problem where files with absolute paths were allowed in torrents

This commit is contained in:
Arvid Norberg 2005-02-24 06:51:59 +00:00
parent 59e66e9c36
commit 4839e509b7
1 changed files with 5 additions and 0 deletions

View File

@ -72,6 +72,9 @@ namespace
{
target.path /= i->string();
}
if (target.path.is_complete()) throw std::runtime_error("torrent contains "
"a file with an absolute path: '"
+ target.path.native_file_string() + "'");
}
void extract_files(const entry::list_type& list, std::vector<file_entry>& target)
@ -187,6 +190,8 @@ namespace libtorrent
// field.
file_entry e;
e.path = m_name;
if (e.path.is_complete()) throw std::runtime_error("torrent contains "
"a file with an absolute path: '" + e.path.native_file_string() + "'");
e.size = info["length"].integer();
m_files.push_back(e);
}