mirror of
https://github.com/sheumann/hush.git
synced 2024-10-31 19:04:47 +00:00
Avoid integer overflow in suffix-processing code.
This commit is contained in:
parent
a0d9884e7e
commit
2a577970b6
@ -725,7 +725,7 @@ void generate_uuid(uint8_t *buf) FAST_FUNC;
|
||||
/* Last element is marked by mult == 0 */
|
||||
struct suffix_mult {
|
||||
char suffix[4];
|
||||
unsigned mult;
|
||||
unsigned long mult;
|
||||
};
|
||||
extern const struct suffix_mult bkm_suffixes[];
|
||||
#define km_suffixes (bkm_suffixes + 1)
|
||||
|
@ -67,7 +67,7 @@ uint16_t FAST_FUNC xatou16(const char *numstr)
|
||||
const struct suffix_mult bkm_suffixes[] = {
|
||||
{ "b", 512 },
|
||||
{ "k", 1024 },
|
||||
{ "m", 1024*1024 },
|
||||
{ "m", 1024L*1024 },
|
||||
{ "", 0 }
|
||||
};
|
||||
|
||||
@ -83,10 +83,10 @@ const struct suffix_mult cwbkMG_suffixes[] = {
|
||||
{ "K", 1024 }, /* compat with coreutils dd */
|
||||
{ "MB", 1000000 },
|
||||
{ "MD", 1000000 },
|
||||
{ "M", 1024*1024 },
|
||||
{ "M", 1024L*1024 },
|
||||
{ "GB", 1000000000 },
|
||||
{ "GD", 1000000000 },
|
||||
{ "G", 1024*1024*1024 },
|
||||
{ "G", 1024L*1024*1024 },
|
||||
/* "D" suffix for decimal is not in coreutils manpage, looks like it's deprecated */
|
||||
/* coreutils also understands TPEZY suffixes for tera- and so on, with B suffix for decimal */
|
||||
{ "", 0 }
|
||||
|
Loading…
Reference in New Issue
Block a user