mirror of
https://github.com/ggrandou/abootimg.git
synced 2024-11-23 09:53:32 +08:00
fix: sigfpe if page_size == 0
* exit if page_size is null * set default page_size to 2048.
This commit is contained in:
parent
8426206447
commit
b4bf230bcb
@ -241,6 +241,9 @@ int check_boot_img_header(t_abootimg* img)
|
||||
return 1;
|
||||
|
||||
unsigned page_size = img->header.page_size;
|
||||
if (!page_size)
|
||||
abort_printf("%s: Image page size is null\n", img->fname);
|
||||
|
||||
unsigned n = (img->header.kernel_size + page_size - 1) / page_size;
|
||||
unsigned m = (img->header.ramdisk_size + page_size - 1) / page_size;
|
||||
unsigned o = (img->header.second_size + page_size - 1) / page_size;
|
||||
@ -452,6 +455,9 @@ void update_images(t_abootimg *img)
|
||||
unsigned rsize = img->header.ramdisk_size;
|
||||
unsigned ssize = img->header.second_size;
|
||||
|
||||
if (!page_size)
|
||||
abort_printf("%s: Image page size is null\n", img->fname);
|
||||
|
||||
unsigned n = (ksize + page_size - 1) / page_size;
|
||||
unsigned m = (rsize + page_size - 1) / page_size;
|
||||
unsigned o = (ssize + page_size - 1) / page_size;
|
||||
@ -825,6 +831,7 @@ t_abootimg* new_bootimg()
|
||||
img->second_fname = "stage2.img";
|
||||
|
||||
memcpy(img->header.magic, BOOT_MAGIC, BOOT_MAGIC_SIZE);
|
||||
img->header.page_size = 2048; // a sensible default page size
|
||||
|
||||
return img;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user