p2p: change CInv::type from int to uint32_t

fixes issue #19678 UBSan implicit-integer-sign-change

Credit to Eugene (Crypt-iQ) for finding and reporting the issue
and to Vasil Dimov (vasild) for the original suggestion
This commit is contained in:
Jon Atack 2020-07-28 10:47:07 +02:00
parent 2562d5d238
commit 407175e0c2
No known key found for this signature in database
GPG key ID: 4F5721B3D0E3921D
2 changed files with 3 additions and 3 deletions

View file

@ -163,7 +163,7 @@ CInv::CInv()
hash.SetNull();
}
CInv::CInv(int typeIn, const uint256& hashIn) : type(typeIn), hash(hashIn) {}
CInv::CInv(uint32_t typeIn, const uint256& hashIn) : type(typeIn), hash(hashIn) {}
bool operator<(const CInv& a, const CInv& b)
{

View file

@ -408,7 +408,7 @@ class CInv
{
public:
CInv();
CInv(int typeIn, const uint256& hashIn);
CInv(uint32_t typeIn, const uint256& hashIn);
SERIALIZE_METHODS(CInv, obj) { READWRITE(obj.type, obj.hash); }
@ -425,7 +425,7 @@ public:
// Combined-message helper methods
bool IsGenTxMsg() const { return type == MSG_TX || type == MSG_WTX || type == MSG_WITNESS_TX; }
int type;
uint32_t type;
uint256 hash;
};