Skip to content

Commit

Permalink
[crm]: Typecast to unit64_t to avoid divide by 0 during overflow (#1550)
Browse files Browse the repository at this point in the history
Fix orchagent crash in case of overflow resulting in divide by 0
  • Loading branch information
prsunny authored and abdosi committed Dec 19, 2020
1 parent bb1b351 commit cea4468
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 cea4468

Please sign in to comment.