]> git.ipfire.org Git - thirdparty/iproute2.git/commit
ip: Fix size_columns() for very large values
authorPetr Machata <petrm@nvidia.com>
Mon, 27 Jun 2022 13:18:21 +0000 (15:18 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Mon, 27 Jun 2022 19:42:11 +0000 (12:42 -0700)
commit024103923a5c826e40c993be4ee2ada5536cb66a
tree810a50065320dfc66311d523bf5d566cf7d98cfd
parented243312e4068442427ad3ba9e13f70196657f1a
ip: Fix size_columns() for very large values

For values near the 64-bit boundary, the iterative application of
powi *= 10 causes powi to overflow without the termination condition of
powi >= val having ever been satisfied. Instead, when determining the
length of the number, iterate val /= 10 and terminate when it's a single
digit.

Fixes: 49437375b6c1 ("ip: dynamically size columns when printing stats")
CC: Tariq Toukan <tariqt@nvidia.com>
CC: Itay Aveksis <itayav@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
ip/ipaddress.c