mirror of
https://github.com/ggrandou/abootimg.git
synced 2024-11-23 09:53:32 +08:00
iside: be verbose when check_boot_img_header fails
This commit is contained in:
parent
bd22314611
commit
6ef3f1acc2
22
abootimg.c
22
abootimg.c
@ -269,18 +269,26 @@ enum command parse_args(int argc, char** argv, t_abootimg* img)
|
||||
|
||||
int check_boot_img_header(t_abootimg* img)
|
||||
{
|
||||
if (strncmp(img->header.magic, BOOT_MAGIC, BOOT_MAGIC_SIZE))
|
||||
if (strncmp(img->header.magic, BOOT_MAGIC, BOOT_MAGIC_SIZE)) {
|
||||
fprintf(stderr, "%s: no Android Magic Value\n", img->fname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!(img->header.kernel_size))
|
||||
if (!(img->header.kernel_size)) {
|
||||
fprintf(stderr, "%s: kernel size is null\n", img->fname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!(img->header.ramdisk_size))
|
||||
if (!(img->header.ramdisk_size)) {
|
||||
fprintf(stderr, "%s: ramdisk size is null\n", img->fname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned page_size = img->header.page_size;
|
||||
if (!page_size)
|
||||
abort_printf("%s: Image page size is null\n", img->fname);
|
||||
if (!page_size) {
|
||||
fprintf(stderr, "%s: Image page size is null\n", img->fname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned n = (img->header.kernel_size + page_size - 1) / page_size;
|
||||
unsigned m = (img->header.ramdisk_size + page_size - 1) / page_size;
|
||||
@ -288,8 +296,10 @@ int check_boot_img_header(t_abootimg* img)
|
||||
|
||||
unsigned total_size = (1+n+m+o)*page_size;
|
||||
|
||||
if (total_size > img->size)
|
||||
if (total_size > img->size) {
|
||||
fprintf(stderr, "%s: sizes mismatches in boot image\n", img->fname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user