]> git.ipfire.org Git - thirdparty/util-linux.git/commit
lib: [strutils] avoid integer overflow on large values
authorDave Reisner <d@falconindy.com>
Tue, 15 Feb 2011 09:06:08 +0000 (10:06 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 15 Feb 2011 09:13:31 +0000 (10:13 +0100)
commitf9e05dafd0fa36b2cb29eb30250dc63039a34bf2
tree8292541ecb2c91f601517f2261960cdd918b164a
parentbf6db55ad58e9bfa3195a54b01d692b7adbf4056
lib: [strutils] avoid integer overflow on large values

This is visible on a 2TB disk via lsblk, where a large partition
incorrectly displays as 1.171798692T instead of 1.8T. This is
corrected by using a uint64_t type instead of a simple int --
consistant with the type used in lsblk.c to represent the raw size in
bytes.

[kzak@redhat.com: - add EiB support
                  - add size_to_human_string() to regression tests]

Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/strutils.c
tests/expected/misc/strtosize