e2image: fix overflow in l2 table processing

For a large partition during e2image capture process
it is possible to overflow offset at multiply operation.
This leads to the situation when data is written to the
position at the start of the image instead of the image end.

Let's use the right cast to avoid integer overflow.

Signed-off-by: Alexey Lyashkov <c17817@cray.com>
Signed-off-by: Artem Blagodarenko <c17828@cray.com>
HPE-bug-id: LUS-9368
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
Artem Blagodarenko 2021-04-22 01:24:48 -04:00 committed by Theodore Ts'o
parent 9ae89fe3a9
commit f11448318f

View File

@ -238,7 +238,7 @@ int qcow2_write_raw_image(int qcow2_fd, int raw_fd,
if (offset == 0) if (offset == 0)
continue; continue;
off_out = (l1_index * img.l2_size) + off_out = ((__u64)l1_index * img.l2_size) +
l2_index; l2_index;
off_out <<= img.cluster_bits; off_out <<= img.cluster_bits;
ret = qcow2_copy_data(qcow2_fd, raw_fd, offset, ret = qcow2_copy_data(qcow2_fd, raw_fd, offset,