1
0
Fork 0
mirror of https://github.com/CTCaer/hekate.git synced 2024-12-27 02:16:02 +00:00

Add corrupted bmp protection

This commit is contained in:
CTCaer 2020-06-14 13:04:13 +03:00
parent 125f000894
commit 0096b91146
2 changed files with 14 additions and 5 deletions

View file

@ -951,11 +951,12 @@ skip_list:
u8 *bitmap = NULL;
if (!(b_cfg.boot_cfg & BOOT_CFG_FROM_LAUNCH) && h_cfg.bootwait && !h_cfg.sept_run)
{
u32 fsize;
if (bootlogoCustomEntry) // Check if user set custom logo path at the boot entry.
bitmap = (u8 *)sd_file_read(bootlogoCustomEntry, NULL);
bitmap = (u8 *)sd_file_read(bootlogoCustomEntry, &fsize);
if (!bitmap) // Custom entry bootlogo not found, trying default custom one.
bitmap = (u8 *)sd_file_read("bootloader/bootlogo.bmp", NULL);
bitmap = (u8 *)sd_file_read("bootloader/bootlogo.bmp", &fsize);
if (bitmap)
{
@ -975,7 +976,7 @@ skip_list:
bmpData.size_x <= 720 &&
bmpData.size_y <= 1280)
{
if ((bmpData.size - bmpData.offset) <= 0x400000)
if (bmpData.size <= fsize && ((bmpData.size - bmpData.offset) < 0x400000))
{
// Avoid unaligned access from BM 2-byte MAGIC and remove header.
BOOTLOGO = (u8 *)malloc(0x400000);

View file

@ -574,7 +574,8 @@ void manual_system_maintenance(bool refresh)
lv_img_dsc_t *bmp_to_lvimg_obj(const char *path)
{
u8 *bitmap = sd_file_read(path, NULL);
u32 fsize;
u8 *bitmap = sd_file_read(path, &fsize);
if (!bitmap)
return NULL;
@ -600,7 +601,8 @@ lv_img_dsc_t *bmp_to_lvimg_obj(const char *path)
// Sanity check.
if (bitmap[0] == 'B' &&
bitmap[1] == 'M' &&
bitmap[28] == 32) // Only 32 bit BMPs allowed.
bitmap[28] == 32 && // Only 32 bit BMPs allowed.
bmpData.size <= fsize)
{
// Check if non-default Bottom-Top.
bool flipped = false;
@ -2191,6 +2193,12 @@ static void _nyx_main_menu(lv_theme_t * th)
}
else if (n_cfg.home_screen)
_create_window_home_launch(NULL);
if (!n_cfg.timeoff)
{
lv_task_t *task_run_clock = lv_task_create(first_time_clock_edit, LV_TASK_ONESHOT, LV_TASK_PRIO_MID, NULL);
lv_task_once(task_run_clock);
}
}
void nyx_load_and_run()