bumped some limits in dump_torrent

This commit is contained in:
Arvid Norberg 2010-12-11 22:00:20 +00:00
parent 29ed03f720
commit 67d1c57b5e
3 changed files with 7 additions and 6 deletions

View File

@ -46,20 +46,20 @@ int main(int argc, char* argv[])
return 1;
}
int item_limit = 100000;
int item_limit = 1000000;
int depth_limit = 1000;
if (argc > 2) item_limit = atoi(argv[2]);
if (argc > 3) depth_limit = atoi(argv[3]);
int size = file_size(argv[1]);
if (size > 10 * 1000000)
if (size > 40 * 1000000)
{
fprintf(stderr, "file too big (%d), aborting\n", size);
return 1;
}
std::vector<char> buf(size);
int ret = load_file(argv[1], buf);
int ret = load_file(argv[1], buf, 40 * 1000000);
if (ret != 0)
{
fprintf(stderr, "failed to load file: %d\n", ret);

View File

@ -221,7 +221,8 @@ namespace libtorrent
typedef libtorrent_exception invalid_torrent_file;
#endif
int TORRENT_EXPORT load_file(std::string const& filename, std::vector<char>& v);
int TORRENT_EXPORT load_file(std::string const& filename
, std::vector<char>& v, int limit = 8000000);
class TORRENT_EXPORT torrent_info : public intrusive_ptr_base<torrent_info>
{

View File

@ -401,14 +401,14 @@ namespace libtorrent
return 1 << i;
}
int load_file(std::string const& filename, std::vector<char>& v)
int load_file(std::string const& filename, std::vector<char>& v, int limit)
{
file f;
error_code ec;
if (!f.open(filename, file::read_only, ec)) return -1;
size_type s = f.get_size(ec);
if (ec) return -1;
if (s > 8000000) return -2;
if (s > limit) return -2;
v.resize(s);
if (s == 0) return 0;
file::iovec_t b = {&v[0], s};