Skip to content

Commit

Permalink
Fix for integer overflow of counter value if its too large (#3596)
Browse files Browse the repository at this point in the history
What I did
Changed the data type casting to float if count coming is too large or in scientific notation .

How I did it
made it float then type cast to int for display purpose

How to verify it
Manually passed big value and see the count output if it breaks or works
  • Loading branch information
harjotsinghpawra authored and mssonicbld committed Nov 7, 2024
1 parent a3b1012 commit 35569c8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion utilities_common/portstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def get_counters(port):
if counter_name not in fvs:
fields[pos] = STATUS_NA
elif fields[pos] != STATUS_NA:
fields[pos] = str(int(fields[pos]) + int(fvs[counter_name]))
fields[pos] = str(int(fields[pos]) + int(float(fvs[counter_name])))

cntr = NStats._make(fields)._asdict()
return cntr
Expand Down

0 comments on commit 35569c8

Please sign in to comment.