diff options
author | Jin Qian <jinqian@google.com> | 2017-03-25 22:21:05 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-03-25 22:21:05 +0000 |
commit | 62e612453d307ad51c9871e1af62be0826058dde (patch) | |
tree | 82250a7e7f7f9b54c2a7d39cd7a55290179ed5c8 | |
parent | 634cfcb3f7003368179592ae2832647921bafbef (diff) | |
parent | 4814dc5fa78fb8fc1899bb1bcf91b502f922670e (diff) | |
download | extras-62e612453d307ad51c9871e1af62be0826058dde.tar.gz |
Merge "ext4_utils: fix crash when filesystem size is too small" am: 7902acdaa0 am: d57a607ac7
am: 4814dc5fa7
Change-Id: I8459f1a3dbdc2bbb84a86f4376d3e2c59239862a
-rw-r--r-- | ext4_utils/ext4_utils.c | 3 | ||||
-rw-r--r-- | ext4_utils/make_ext4fs.c | 10 |
2 files changed, 8 insertions, 5 deletions
diff --git a/ext4_utils/ext4_utils.c b/ext4_utils/ext4_utils.c index 550181f3..07a92119 100644 --- a/ext4_utils/ext4_utils.c +++ b/ext4_utils/ext4_utils.c @@ -222,6 +222,9 @@ void ext4_create_fs_aux_info() if (ext4_bg_has_super_block(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) { + critical_error("filesystem size too small"); + } if (last_group_size > 0 && last_group_size < last_header_size) { aux_info.groups--; aux_info.len_blocks -= last_group_size; diff --git a/ext4_utils/make_ext4fs.c b/ext4_utils/make_ext4fs.c index b84db9b3..58069f31 100644 --- a/ext4_utils/make_ext4fs.c +++ b/ext4_utils/make_ext4fs.c @@ -753,17 +753,17 @@ int make_ext4fs_internal(int fd, const char *_directory, const char *_target_out if (info.len <= 0) info.len = get_file_size(fd); - if (info.len <= 0) { - fprintf(stderr, "Need size of filesystem\n"); - return EXIT_FAILURE; - } - if (info.block_size <= 0) info.block_size = compute_block_size(); /* Round down the filesystem length to be a multiple of the block size */ info.len &= ~((u64)info.block_size - 1); + if (info.len <= 0) { + fprintf(stderr, "filesystem size too small\n"); + return EXIT_FAILURE; + } + if (info.journal_blocks == 0) info.journal_blocks = compute_journal_blocks(); |