mirror of https://github.com/aria2/aria2
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
parent
cfd0a40fdb
commit
3274b6acc7
|
@ -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>
|
2008-02-21 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
Proper return value handling for OpenSSL functions.
|
Proper return value handling for OpenSSL functions.
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
|
#include "PeerMessageUtil.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <functional>
|
#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> DefaultBtContext::computeFastSet(const std::string& ipaddr, int32_t fastSetSize)
|
||||||
{
|
{
|
||||||
std::deque<int32_t> fastSet;
|
std::deque<int32_t> fastSet;
|
||||||
struct in_addr saddr;
|
char compact[6];
|
||||||
if(inet_aton(ipaddr.c_str(), &saddr) == 0) {
|
PeerMessageUtil::createcompact(compact, ipaddr, 0);
|
||||||
abort();
|
|
||||||
}
|
|
||||||
unsigned char tx[24];
|
unsigned char tx[24];
|
||||||
memcpy(tx, (void*)&saddr.s_addr, 4);
|
memcpy(tx, compact, 4);
|
||||||
if((tx[0] & 0x80) == 0 || (tx[0] & 0x40) == 0) {
|
if((tx[0] & 0x80) == 0 || (tx[0] & 0x40) == 0) {
|
||||||
tx[2] = 0x00;
|
tx[2] = 0x00;
|
||||||
tx[3] = 0x00;
|
tx[3] = 0x00;
|
||||||
|
|
|
@ -380,8 +380,7 @@ void DefaultBtInteractive::addPeerExchangeMessage()
|
||||||
i != peers.end() && max; ++i) {
|
i != peers.end() && max; ++i) {
|
||||||
const PeerHandle& cpeer = *i;
|
const PeerHandle& cpeer = *i;
|
||||||
if(peer->ipaddr != cpeer->ipaddr &&
|
if(peer->ipaddr != cpeer->ipaddr &&
|
||||||
!cpeer->getFirstContactTime().elapsed(interval) &&
|
!cpeer->getFirstContactTime().elapsed(interval)) {
|
||||||
Util::isNumbersAndDotsNotation(cpeer->ipaddr)) {
|
|
||||||
m->addFreshPeer(cpeer);
|
m->addFreshPeer(cpeer);
|
||||||
--max;
|
--max;
|
||||||
}
|
}
|
||||||
|
@ -393,8 +392,7 @@ void DefaultBtInteractive::addPeerExchangeMessage()
|
||||||
i != peers.rend() && max; ++i) {
|
i != peers.rend() && max; ++i) {
|
||||||
const PeerHandle& cpeer = *i;
|
const PeerHandle& cpeer = *i;
|
||||||
if(peer->ipaddr != cpeer->ipaddr &&
|
if(peer->ipaddr != cpeer->ipaddr &&
|
||||||
!cpeer->getBadConditionStartTime().elapsed(interval) &&
|
!cpeer->getBadConditionStartTime().elapsed(interval)) {
|
||||||
Util::isNumbersAndDotsNotation(cpeer->ipaddr)) {
|
|
||||||
m->addDroppedPeer(cpeer);
|
m->addDroppedPeer(cpeer);
|
||||||
--max;
|
--max;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue