Make CNetAddr::GetHash() return an unsigned val.
This prevents an undefined operation in main.cpp, when shifting the hash value left by 32 bits. Shifting a signed int left into the sign bit is undefined in C++11.
This commit is contained in:
parent
1653f97c8f
commit
4843b55fd1
@ -2440,7 +2440,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||||||
static uint256 hashSalt;
|
static uint256 hashSalt;
|
||||||
if (hashSalt == 0)
|
if (hashSalt == 0)
|
||||||
RAND_bytes((unsigned char*)&hashSalt, sizeof(hashSalt));
|
RAND_bytes((unsigned char*)&hashSalt, sizeof(hashSalt));
|
||||||
int64 hashAddr = addr.GetHash();
|
uint64 hashAddr = addr.GetHash();
|
||||||
uint256 hashRand = hashSalt ^ (hashAddr<<32) ^ ((GetTime()+hashAddr)/(24*60*60));
|
uint256 hashRand = hashSalt ^ (hashAddr<<32) ^ ((GetTime()+hashAddr)/(24*60*60));
|
||||||
hashRand = Hash(BEGIN(hashRand), END(hashRand));
|
hashRand = Hash(BEGIN(hashRand), END(hashRand));
|
||||||
multimap<uint256, CNode*> mapMix;
|
multimap<uint256, CNode*> mapMix;
|
||||||
|
@ -820,10 +820,10 @@ std::vector<unsigned char> CNetAddr::GetGroup() const
|
|||||||
return vchRet;
|
return vchRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64 CNetAddr::GetHash() const
|
uint64 CNetAddr::GetHash() const
|
||||||
{
|
{
|
||||||
uint256 hash = Hash(&ip[0], &ip[16]);
|
uint256 hash = Hash(&ip[0], &ip[16]);
|
||||||
int64 nRet;
|
uint64 nRet;
|
||||||
memcpy(&nRet, &hash, sizeof(nRet));
|
memcpy(&nRet, &hash, sizeof(nRet));
|
||||||
return nRet;
|
return nRet;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ class CNetAddr
|
|||||||
std::string ToString() const;
|
std::string ToString() const;
|
||||||
std::string ToStringIP() const;
|
std::string ToStringIP() const;
|
||||||
int GetByte(int n) const;
|
int GetByte(int n) const;
|
||||||
int64 GetHash() const;
|
uint64 GetHash() const;
|
||||||
bool GetInAddr(struct in_addr* pipv4Addr) const;
|
bool GetInAddr(struct in_addr* pipv4Addr) const;
|
||||||
std::vector<unsigned char> GetGroup() const;
|
std::vector<unsigned char> GetGroup() const;
|
||||||
int GetReachabilityFrom(const CNetAddr *paddrPartner = NULL) const;
|
int GetReachabilityFrom(const CNetAddr *paddrPartner = NULL) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user