Skip to content

Commit dfa174c

Browse files
committed
CAddrDB/CBanDB: change filesize variables from int to uint64_t
1 parent f581d3d commit dfa174c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/net.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,11 +1973,11 @@ bool CAddrDB::Read(CAddrMan& addr)
19731973
return error("%s: Failed to open file %s", __func__, pathAddr.string());
19741974

19751975
// use file size to size memory buffer
1976-
int fileSize = boost::filesystem::file_size(pathAddr);
1977-
int dataSize = fileSize - sizeof(uint256);
1976+
uint64_t fileSize = boost::filesystem::file_size(pathAddr);
1977+
uint64_t dataSize = 0;
19781978
// Don't try to resize to a negative number if file is small
1979-
if (dataSize < 0)
1980-
dataSize = 0;
1979+
if (fileSize >= sizeof(uint256))
1980+
dataSize = fileSize - sizeof(uint256);
19811981
vector<unsigned char> vchData;
19821982
vchData.resize(dataSize);
19831983
uint256 hashIn;
@@ -2230,11 +2230,11 @@ bool CBanDB::Read(std::map<CSubNet, int64_t>& banSet)
22302230
return error("%s: Failed to open file %s", __func__, pathBanlist.string());
22312231

22322232
// use file size to size memory buffer
2233-
int fileSize = boost::filesystem::file_size(pathBanlist);
2234-
int dataSize = fileSize - sizeof(uint256);
2233+
uint64_t fileSize = boost::filesystem::file_size(pathBanlist);
2234+
uint64_t dataSize = 0;
22352235
// Don't try to resize to a negative number if file is small
2236-
if (dataSize < 0)
2237-
dataSize = 0;
2236+
if (fileSize >= sizeof(uint256))
2237+
dataSize = fileSize - sizeof(uint256);
22382238
vector<unsigned char> vchData;
22392239
vchData.resize(dataSize);
22402240
uint256 hashIn;

0 commit comments

Comments
 (0)