mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
(size_trunc_len): fixed potential integer overflow if SI is used.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
6dabcb5f55
commit
6273917e33
@ -431,7 +431,6 @@ size_trunc_len (char *buffer, unsigned int len, uintmax_t size, int units, gbool
|
||||
static const char *const suffix[] = { "", "K", "M", "G", "T", "P", "E", "Z", "Y", NULL };
|
||||
static const char *const suffix_lc[] = { "", "k", "m", "g", "t", "p", "e", "z", "y", NULL };
|
||||
int j = 0;
|
||||
int size_remain;
|
||||
|
||||
if (len == 0)
|
||||
len = 9;
|
||||
@ -453,6 +452,8 @@ size_trunc_len (char *buffer, unsigned int len, uintmax_t size, int units, gbool
|
||||
if (use_si)
|
||||
for (j = 0; j < units; j++)
|
||||
{
|
||||
uintmax_t size_remain;
|
||||
|
||||
size_remain = ((size % 125) * 1024) / 1000; /* size mod 125, recalculated */
|
||||
size = size / 125; /* 128/125 = 1024/1000 */
|
||||
size = size * 128; /* This will convert size from multiple of 1024 to multiple of 1000 */
|
||||
|
Loading…
Reference in New Issue
Block a user