fix issue with the name in single file torrents being sanitized away
This commit is contained in:
parent
12e92aeeb4
commit
9d276ada8a
|
@ -370,8 +370,6 @@ restart_response:
|
|||
if (chunk_size == 0)
|
||||
{
|
||||
m_finished = true;
|
||||
TORRENT_ASSERT(m_content_length < 0 || m_recv_pos - m_body_start_pos
|
||||
- m_chunk_header_size == m_content_length);
|
||||
}
|
||||
header_size -= m_partial_chunk_header;
|
||||
m_partial_chunk_header = 0;
|
||||
|
|
|
@ -407,6 +407,11 @@ namespace {
|
|||
filename = p.string_ptr() + info_ptr_diff;
|
||||
filename_len = p.string_length();
|
||||
sanitize_append_path_element(path, p.string_value());
|
||||
if (path.empty())
|
||||
{
|
||||
ec = errors::torrent_missing_name;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -657,3 +657,26 @@ TORRENT_TEST(invalid_chunk_2)
|
|||
feed_bytes(parser, {reinterpret_cast<char const*>(invalid_chunked_input), sizeof(invalid_chunked_input)});
|
||||
}
|
||||
|
||||
TORRENT_TEST(invalid_chunk_3)
|
||||
{
|
||||
std::uint8_t const invalid_chunked_input[] = {
|
||||
0x48, 0xff, 0xff, 0xff, 0xfd, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, 0x20, 0x32, 0x30, 0x30, // H....TTP/1.1 200
|
||||
0x20, 0x4f, 0x4b, 0x0a, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x2d, 0x45, 0x6e, 0x63, // OK.Transfer-Enc
|
||||
0x6f, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x65, 0x64, 0x0a, 0x44, // oding: chunked.D
|
||||
0x61, 0x74, 0x65, 0x3a, 0x20, 0x53, 0x61, 0x74, 0x2c, 0x20, 0x33, 0x31, 0x20, 0x41, 0x75, 0x67, // ate: Sat, 0x31, Aug
|
||||
0x20, 0x32, 0x30, 0x30, 0x32, 0x20, 0x30, 0x30, 0x3a, 0x32, 0x34, 0x3a, 0x30, 0x38, 0x20, 0x47, // 2002 0x00,:0x24,:0x08, G
|
||||
0x4d, 0x54, 0x0a, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, // MT.Connection: c
|
||||
0x6c, 0x6f, 0x73, 0x65, 0x0a, 0x0a, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, // lose..0000000000
|
||||
0x36, 0x34, 0x0a, 0x6c, 0x72, 0x79, 0x6d, 0x68, 0x74, 0x67, 0x6b, 0x7a, 0x71, 0x74, 0x71, 0x71, // 0x64,.lrymhtgkzqtqq
|
||||
0x62, 0x75, 0x71, 0x69, 0x66, 0x76, 0x69, 0x74, 0x6b, 0x70, 0x69, 0x63, 0x6f, 0x64, 0x67, 0x77, // buqifvitkpicodgw
|
||||
0x6d, 0x69, 0x6a, 0x64, 0x67, 0x76, 0x6b, 0x63, 0x65, 0x78, 0x64, 0x75, 0x71, 0x74, 0x6e, 0x74, // mijdgvkcexduqtnt
|
||||
0x6e, 0x66, 0x62, 0x75, 0x64, 0x6d, 0x6e, 0x6e, 0x62, 0x78, 0x72, 0x72, 0x63, 0x78, 0x6e, 0x70, // nfbudmnnbxrrcxnp
|
||||
0x66, 0x79, 0x73, 0x6f, 0x74, 0x66, 0x71, 0x7a, 0x63, 0x74, 0x77, 0x75, 0x6d, 0x6a, 0x6e, 0x63, // fysotfqzctwumjnc
|
||||
0x6f, 0x71, 0x77, 0x72, 0x63, 0x6d, 0x67, 0x64, 0x6c, 0x78, 0x77, 0x6f, 0x78, 0x6c, 0x64, 0x65, // oqwrcmgdlxwoxlde
|
||||
0x6a, 0x76, 0x73, 0x66, 0x63, 0x6b, 0x65, 0x0a, 0x30, 0x0a, 0x0a, 0x0a, // jvsfcke.0...
|
||||
};
|
||||
|
||||
http_parser parser;
|
||||
feed_bytes(parser, {reinterpret_cast<char const*>(invalid_chunked_input), sizeof(invalid_chunked_input)});
|
||||
}
|
||||
|
||||
|
|
|
@ -140,6 +140,7 @@ test_failing_torrent_t test_error_torrents[] =
|
|||
{ "invalid_piece_len.torrent", errors::torrent_missing_piece_length },
|
||||
{ "negative_piece_len.torrent", errors::torrent_missing_piece_length },
|
||||
{ "no_name.torrent", errors::torrent_missing_name },
|
||||
{ "bad_name.torrent", errors::torrent_missing_name },
|
||||
{ "invalid_name.torrent", errors::torrent_missing_name },
|
||||
{ "invalid_info.torrent", errors::torrent_missing_info },
|
||||
{ "string.torrent", errors::torrent_is_no_dict },
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue