2008-02-21 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Fixed segmentation fault when a DHT message which doesn't have 
'y' key
	received.
	* src/DHTMessageReceiver.cc (receiveMessage)
pull/1/head
Tatsuhiro Tsujikawa 2008-02-20 16:52:09 +00:00
parent c4aaea3ca2
commit 1ea9033363
2 changed files with 13 additions and 2 deletions

View File

@ -1,3 +1,9 @@
2008-02-21 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed segmentation fault when a DHT message which doesn't have 'y' key
received.
* src/DHTMessageReceiver.cc (receiveMessage)
2008-02-21 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com> 2008-02-21 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed the bug that a return code is always 0. BUG#1897704 Fixed the bug that a return code is always 0. BUG#1897704

View File

@ -78,8 +78,13 @@ SharedHandle<DHTMessage> DHTMessageReceiver::receiveMessage()
const Dictionary* d = dynamic_cast<const Dictionary*>(msgroot.get()); const Dictionary* d = dynamic_cast<const Dictionary*>(msgroot.get());
if(d) { if(d) {
const Data* y = dynamic_cast<const Data*>(d->get("y")); const Data* y = dynamic_cast<const Data*>(d->get("y"));
if(y->toString() == "r" || y->toString() == "e") { if(y) {
isReply = true; if(y->toString() == "r" || y->toString() == "e") {
isReply = true;
}
} else {
_logger->info("Malformed DHT message. Missing 'y' key. From:%s:%u", remoteAddr.c_str(), remotePort);
return handleUnknownMessage(data, sizeof(data), remoteAddr, remotePort);
} }
} else { } else {
_logger->info("Malformed DHT message. This is not a bencoded directory. From:%s:%u", remoteAddr.c_str(), remotePort); _logger->info("Malformed DHT message. This is not a bencoded directory. From:%s:%u", remoteAddr.c_str(), remotePort);