case BT_BITFIELD:
if (tr_torrentHasMetadata (msg->torrent))
- return len == (msg->torrent->info.pieceCount + 7u) / 8u + 1u;
+ return len == (msg->torrent->info.pieceCount >> 3) + (msg->torrent->info.pieceCount & 7 ? 1 : 0) + 1u;
/* we don't know the piece count yet,
so we can only guess whether to send true or false */
if (msg->metadata_size_hint > 0)
#endif
const bool fext = tr_peerIoSupportsFEXT (msgs->io);
+ assert (msglen > 0);
+
--msglen; /* id length */
dbgmsg (msgs, "got BT id %d, len %d, buffer size is %"TR_PRIuSIZE, (int)id, (int)msglen, inlen);