Skip to content

Commit

Permalink
[util] Avoid integer overflow in CheckDiskSpace
Browse files Browse the repository at this point in the history
  • Loading branch information
dergoegge committed Mar 10, 2023
1 parent 40c6c85 commit 4517419
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1631,10 +1631,11 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)

// On first startup, warn on low block storage space
if (!fReindex && !fReindexChainState && chain_active_height <= 1) {
uint64_t assumed_chain_bytes{chainparams.AssumedBlockchainSize() * 1024 * 1024 * 1024};
uint64_t additional_bytes_needed{
chainman.m_blockman.IsPruneMode() ?
chainman.m_blockman.GetPruneTarget() :
chainparams.AssumedBlockchainSize() * 1024 * 1024 * 1024};
std::min(chainman.m_blockman.GetPruneTarget(), assumed_chain_bytes) :
assumed_chain_bytes};

if (!CheckDiskSpace(args.GetBlocksDirPath(), additional_bytes_needed)) {
InitWarning(strprintf(_(
Expand Down

0 comments on commit 4517419

Please sign in to comment.