CID
1019568 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
overflow_before_widen: Potentially overflowing expression "1 << *order" with
type "int" (32 bits, signed) is evaluated using 32-bit arithmetic before being
used in a context which expects an expression of type "uint64_t" (64 bits,
unsigned). To avoid overflow, cast the left operand to "uint64_t" before
performing the left shift.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
bool from_stdin = !strcmp(path, "-");
if (from_stdin) {
fd = 0;
- size = 1 << *order;
+ size = 1ULL << *order;
} else {
fd = open(path, O_RDONLY);