Skip to content

Commit

Permalink
[crm]: Typecast to unit64_t to avoid divide by 0 during overflow (son…
Browse files Browse the repository at this point in the history
…ic-net#1550)

Fix orchagent crash in case of overflow resulting in divide by 0
  • Loading branch information
prsunny authored Dec 17, 2020
1 parent 05ef220 commit e1dd327
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion orchagent/crmorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ void CrmOrch::checkCrmThresholds()

if (cnt.usedCounter != 0)
{
percentageUtil = (cnt.usedCounter * 100) / (cnt.usedCounter + cnt.availableCounter);
percentageUtil = (uint32_t)((cnt.usedCounter * 100) / (uint64_t)(cnt.usedCounter + cnt.availableCounter));
}

switch (res.thresholdType)
Expand Down

0 comments on commit e1dd327

Please sign in to comment.