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

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)
pull/1/head
Tatsuhiro Tsujikawa 2008-02-20 17:45:22 +00:00
parent cfd0a40fdb
commit 3274b6acc7
3 changed files with 15 additions and 9 deletions

View File

@ -1,3 +1,12 @@
2008-02-21 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
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 <tujikawa at rednoah dot com>
Proper return value handling for OpenSSL functions.

View File

@ -48,6 +48,7 @@
#include "Logger.h"
#include "FileEntry.h"
#include "message.h"
#include "PeerMessageUtil.h"
#include <cstring>
#include <ostream>
#include <functional>
@ -385,12 +386,10 @@ std::string DefaultBtContext::getActualBasePath() const
std::deque<int32_t> DefaultBtContext::computeFastSet(const std::string& ipaddr, int32_t fastSetSize)
{
std::deque<int32_t> 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;

View File

@ -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;
}