fixing bug where the trailing bits in bitfields were not set to 0. Fixes #482

This commit is contained in:
Arvid Norberg
2009-02-06 08:51:25 +00:00
parent bcd93da465
commit 7607286f50
2 changed files with 15 additions and 4 deletions

View File

@@ -1563,7 +1563,11 @@ namespace libtorrent
if (t->is_seed())
{
memset(i.begin, 0xff, packet_size - 5);
memset(i.begin, 0xff, packet_size - 6);
// Clear trailing bits
unsigned char *p = ((unsigned char *)i.begin) + packet_size - 6;
*p = (0xff << ((8 - (num_pieces & 7)) & 7)) & 0xff;
}
else
{