|
@@ -60,7 +60,8 @@ uint16_t PeerMessageUtil::getShortIntParam(const unsigned char* msg, size_t pos)
|
|
|
|
|
|
void PeerMessageUtil::checkIndex(size_t index, size_t pieces) {
|
|
|
if(!(index < pieces)) {
|
|
|
- throw DlAbortEx(StringFormat("Invalid index: %zu", index).str());
|
|
|
+ throw DlAbortEx(StringFormat("Invalid index: %lu",
|
|
|
+ static_cast<unsigned long>(index)).str());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -72,23 +73,27 @@ void PeerMessageUtil::checkBegin(uint32_t begin, size_t pieceLength) {
|
|
|
|
|
|
void PeerMessageUtil::checkLength(size_t length) {
|
|
|
if(length > MAX_BLOCK_LENGTH) {
|
|
|
- throw DlAbortEx(StringFormat("Length too long: %zu > %uKB", length,
|
|
|
+ throw DlAbortEx(StringFormat("Length too long: %lu > %uKB",
|
|
|
+ static_cast<unsigned long>(length),
|
|
|
MAX_BLOCK_LENGTH/1024).str());
|
|
|
}
|
|
|
if(length == 0) {
|
|
|
- throw DlAbortEx(StringFormat("Invalid length: %zu", length).str());
|
|
|
+ throw DlAbortEx(StringFormat("Invalid length: %lu",
|
|
|
+ static_cast<unsigned long>(length)).str());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void PeerMessageUtil::checkRange(uint32_t begin, size_t length, size_t pieceLength) {
|
|
|
if(!(0 < length)) {
|
|
|
- throw DlAbortEx(StringFormat("Invalid range: begin=%u, length=%zu",
|
|
|
- begin, length).str());
|
|
|
+ throw DlAbortEx(StringFormat("Invalid range: begin=%u, length=%lu",
|
|
|
+ begin,
|
|
|
+ static_cast<unsigned long>(length)).str());
|
|
|
}
|
|
|
uint32_t end = begin+length;
|
|
|
if(!(end <= pieceLength)) {
|
|
|
- throw DlAbortEx(StringFormat("Invalid range: begin=%u, length=%zu",
|
|
|
- begin, length).str());
|
|
|
+ throw DlAbortEx(StringFormat("Invalid range: begin=%u, length=%lu",
|
|
|
+ begin,
|
|
|
+ static_cast<unsigned long>(length)).str());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -96,8 +101,9 @@ void PeerMessageUtil::checkBitfield(const unsigned char* bitfield,
|
|
|
size_t bitfieldLength,
|
|
|
size_t pieces) {
|
|
|
if(!(bitfieldLength == (pieces+7)/8)) {
|
|
|
- throw DlAbortEx(StringFormat("Invalid bitfield length: %zu",
|
|
|
- bitfieldLength).str());
|
|
|
+ throw DlAbortEx
|
|
|
+ (StringFormat("Invalid bitfield length: %lu",
|
|
|
+ static_cast<unsigned long>(bitfieldLength)).str());
|
|
|
}
|
|
|
char lastbyte = bitfield[bitfieldLength-1];
|
|
|
for(size_t i = 0; i < 8-pieces%8 && pieces%8 != 0; ++i) {
|