fix on_piece to check if header is received before parsing it

This commit is contained in:
Arvid Norberg 2009-03-19 16:50:37 +00:00
parent 31054ef069
commit 7e01b9d990
1 changed files with 4 additions and 1 deletions

View File

@ -1150,12 +1150,15 @@ namespace libtorrent
piece_bytes = recv_pos - 9;
}
const int header_size = merkle?13:9;
if (recv_pos < header_size) return;
const char* ptr = recv_buffer.begin + 1;
peer_request p;
p.piece = detail::read_int32(ptr);
p.start = detail::read_int32(ptr);
const int header_size = merkle?13:9;
int list_size = 0;
if (merkle)