Skip to content

Commit 7c16635

Browse files
committed
btrfs-progs: check: widen type for checksum bytes multiplication
CodeQL reports potential truncation of the 'data_len' due to u16 * u32. Force the result type to avoid the problem. Signed-off-by: David Sterba <[email protected]>
1 parent a0cd15c commit 7c16635

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

check/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6131,7 +6131,7 @@ static int check_csum_root(struct btrfs_root *root)
61316131
errors++;
61326132
}
61336133
num_entries = btrfs_item_size(leaf, path.slots[0]) / csum_size;
6134-
data_len = num_entries * gfs_info->sectorsize;
6134+
data_len = (u64)num_entries * gfs_info->sectorsize;
61356135

61366136
if (num_entries > max_entries) {
61376137
error(
@@ -9816,7 +9816,7 @@ static int check_range_csummed(struct btrfs_root *root, u64 addr, u64 length)
98169816
break;
98179817

98189818
num_entries = btrfs_item_size(leaf, path.slots[0]) / gfs_info->csum_size;
9819-
data_len = num_entries * gfs_info->sectorsize;
9819+
data_len = (u64)num_entries * gfs_info->sectorsize;
98209820

98219821
if (addr >= key.offset && addr <= key.offset + data_len) {
98229822
u64 end = min(addr + length, key.offset + data_len);

0 commit comments

Comments
 (0)