diff --git a/ChangeLog b/ChangeLog index 4de39e27..ea0069f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-02-21 Tatsuhiro Tsujikawa + + Fixed abort when peer's ip address is IPv4-mapped address. + * src/DefaultBtContext.cc (computeFastSet) + + Removed number-and-dots criteria, since Util::isNumberAndDotsNotation() + cannot handle IPv4-mapped addresses. + * src/DefaultBtInteractive.cc (addPeerExchangeMessage) + 2008-02-21 Tatsuhiro Tsujikawa Proper return value handling for OpenSSL functions. diff --git a/src/DefaultBtContext.cc b/src/DefaultBtContext.cc index f25b323f..23378656 100644 --- a/src/DefaultBtContext.cc +++ b/src/DefaultBtContext.cc @@ -48,6 +48,7 @@ #include "Logger.h" #include "FileEntry.h" #include "message.h" +#include "PeerMessageUtil.h" #include #include #include @@ -385,12 +386,10 @@ std::string DefaultBtContext::getActualBasePath() const std::deque DefaultBtContext::computeFastSet(const std::string& ipaddr, int32_t fastSetSize) { std::deque fastSet; - struct in_addr saddr; - if(inet_aton(ipaddr.c_str(), &saddr) == 0) { - abort(); - } + char compact[6]; + PeerMessageUtil::createcompact(compact, ipaddr, 0); unsigned char tx[24]; - memcpy(tx, (void*)&saddr.s_addr, 4); + memcpy(tx, compact, 4); if((tx[0] & 0x80) == 0 || (tx[0] & 0x40) == 0) { tx[2] = 0x00; tx[3] = 0x00; diff --git a/src/DefaultBtInteractive.cc b/src/DefaultBtInteractive.cc index 80f59a10..1b2de239 100644 --- a/src/DefaultBtInteractive.cc +++ b/src/DefaultBtInteractive.cc @@ -380,8 +380,7 @@ void DefaultBtInteractive::addPeerExchangeMessage() i != peers.end() && max; ++i) { const PeerHandle& cpeer = *i; if(peer->ipaddr != cpeer->ipaddr && - !cpeer->getFirstContactTime().elapsed(interval) && - Util::isNumbersAndDotsNotation(cpeer->ipaddr)) { + !cpeer->getFirstContactTime().elapsed(interval)) { m->addFreshPeer(cpeer); --max; } @@ -393,8 +392,7 @@ void DefaultBtInteractive::addPeerExchangeMessage() i != peers.rend() && max; ++i) { const PeerHandle& cpeer = *i; if(peer->ipaddr != cpeer->ipaddr && - !cpeer->getBadConditionStartTime().elapsed(interval) && - Util::isNumbersAndDotsNotation(cpeer->ipaddr)) { + !cpeer->getBadConditionStartTime().elapsed(interval)) { m->addDroppedPeer(cpeer); --max; }