summaryrefslogtreecommitdiff
path: root/ext4_utils
diff options
context:
space:
mode:
authorIvan Lozano <ivanlozano@google.com>2018-01-19 15:11:16 -0800
committerIvan Lozano <ivanlozano@google.com>2018-01-19 15:11:16 -0800
commit53bb71bb6ed73528f237e8621320d6e6e4403a8e (patch)
tree9b05395f4ebda1d9f428906e63cab497d419ebb2 /ext4_utils
parenta409f7533e10b4f281ba2f74c85328b8f3c6eb4a (diff)
downloadextras-53bb71bb6ed73528f237e8621320d6e6e4403a8e.tar.gz
Fix overflow sanitizer in ext4_utils.
The overflow sanitizer was causing the following runtime errors: runtime error: unsigned integer overflow: 1048576 * 1048576 cannot be represented in type 'unsigned int' runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'unsigned int' Use u64 rather than u32 and explicitly cast aux_info.groups to an int before passing it to ext4_bg_has_super_block. Bug: 72226337 Test: Boots without runtime errors. Change-Id: I12fc37e4f0956ca4367209d8efde3e0ecba15114
Diffstat (limited to 'ext4_utils')
-rw-r--r--ext4_utils/ext4_utils.c2
-rw-r--r--ext4_utils/include/ext4_utils/ext4_utils.h6
2 files changed, 4 insertions, 4 deletions
diff --git a/ext4_utils/ext4_utils.c b/ext4_utils/ext4_utils.c
index d7a2fe79..cbfd350f 100644
--- a/ext4_utils/ext4_utils.c
+++ b/ext4_utils/ext4_utils.c
@@ -125,7 +125,7 @@ void ext4_create_fs_aux_info()
u32 last_group_size = aux_info.len_blocks % info.blocks_per_group;
u32 last_header_size = 2 + aux_info.inode_table_blocks;
- if (ext4_bg_has_super_block(aux_info.groups - 1))
+ if (ext4_bg_has_super_block((int)aux_info.groups - 1))
last_header_size += 1 + aux_info.bg_desc_blocks +
info.bg_desc_reserve_blocks;
if (aux_info.groups <= 1 && last_group_size < last_header_size) {
diff --git a/ext4_utils/include/ext4_utils/ext4_utils.h b/ext4_utils/include/ext4_utils/ext4_utils.h
index 17df3a93..27156145 100644
--- a/ext4_utils/include/ext4_utils/ext4_utils.h
+++ b/ext4_utils/include/ext4_utils/ext4_utils.h
@@ -117,9 +117,9 @@ struct fs_aux_info {
u32 groups;
u32 bg_desc_blocks;
u32 default_i_flags;
- u32 blocks_per_ind;
- u32 blocks_per_dind;
- u32 blocks_per_tind;
+ u64 blocks_per_ind;
+ u64 blocks_per_dind;
+ u64 blocks_per_tind;
};
extern struct fs_info info;