hekate/nyx: use zalloc where appropriate

This commit is contained in:
CTCaer 2024-03-27 09:16:06 +02:00
parent d687b53249
commit 4effaab241
12 changed files with 68 additions and 196 deletions

View file

@ -218,7 +218,7 @@ static void _hos_eks_get()
if (!h_cfg.eks) if (!h_cfg.eks)
{ {
// Read EKS blob. // Read EKS blob.
u8 *mbr = calloc(SD_BLOCKSIZE, 1); u8 *mbr = zalloc(SD_BLOCKSIZE);
if (!hos_eks_rw_try(mbr, false)) if (!hos_eks_rw_try(mbr, false))
goto out; goto out;
@ -248,7 +248,7 @@ static void _hos_eks_save()
bool new_eks = false; bool new_eks = false;
if (!h_cfg.eks) if (!h_cfg.eks)
{ {
h_cfg.eks = calloc(SD_BLOCKSIZE, 1); h_cfg.eks = zalloc(SD_BLOCKSIZE);
new_eks = true; new_eks = true;
} }
@ -256,7 +256,7 @@ static void _hos_eks_save()
if (h_cfg.eks->enabled != HOS_EKS_TSEC_VER) if (h_cfg.eks->enabled != HOS_EKS_TSEC_VER)
{ {
// Read EKS blob. // Read EKS blob.
u8 *mbr = calloc(SD_BLOCKSIZE, 1); u8 *mbr = zalloc(SD_BLOCKSIZE);
if (!hos_eks_rw_try(mbr, false)) if (!hos_eks_rw_try(mbr, false))
{ {
if (new_eks) if (new_eks)
@ -269,7 +269,7 @@ static void _hos_eks_save()
} }
// Get keys. // Get keys.
u8 *keys = (u8 *)calloc(SZ_4K, 2); u8 *keys = (u8 *)zalloc(SZ_8K);
se_get_aes_keys(keys + SZ_4K, keys, SE_KEY_128_SIZE); se_get_aes_keys(keys + SZ_4K, keys, SE_KEY_128_SIZE);
// Set magic and personalized info. // Set magic and personalized info.
@ -283,7 +283,7 @@ static void _hos_eks_save()
memcpy(h_cfg.eks->troot_dev, keys + 11 * SE_KEY_128_SIZE, SE_KEY_128_SIZE); memcpy(h_cfg.eks->troot_dev, keys + 11 * SE_KEY_128_SIZE, SE_KEY_128_SIZE);
// Encrypt EKS blob. // Encrypt EKS blob.
u8 *eks = calloc(SD_BLOCKSIZE, 1); u8 *eks = zalloc(SD_BLOCKSIZE);
memcpy(eks, h_cfg.eks, sizeof(hos_eks_mbr_t)); memcpy(eks, h_cfg.eks, sizeof(hos_eks_mbr_t));
se_aes_crypt_ecb(14, ENCRYPT, eks, sizeof(hos_eks_mbr_t), eks, sizeof(hos_eks_mbr_t)); se_aes_crypt_ecb(14, ENCRYPT, eks, sizeof(hos_eks_mbr_t), eks, sizeof(hos_eks_mbr_t));
@ -310,7 +310,7 @@ void hos_eks_clear(u32 kb)
if (h_cfg.eks->enabled) if (h_cfg.eks->enabled)
{ {
// Read EKS blob. // Read EKS blob.
u8 *mbr = calloc(SD_BLOCKSIZE, 1); u8 *mbr = zalloc(SD_BLOCKSIZE);
if (!hos_eks_rw_try(mbr, false)) if (!hos_eks_rw_try(mbr, false))
goto out; goto out;
@ -318,7 +318,7 @@ void hos_eks_clear(u32 kb)
h_cfg.eks->enabled = 0; h_cfg.eks->enabled = 0;
// Encrypt EKS blob. // Encrypt EKS blob.
u8 *eks = calloc(SD_BLOCKSIZE, 1); u8 *eks = zalloc(SD_BLOCKSIZE);
memcpy(eks, h_cfg.eks, sizeof(hos_eks_mbr_t)); memcpy(eks, h_cfg.eks, sizeof(hos_eks_mbr_t));
se_aes_crypt_ecb(14, ENCRYPT, eks, sizeof(hos_eks_mbr_t), eks, sizeof(hos_eks_mbr_t)); se_aes_crypt_ecb(14, ENCRYPT, eks, sizeof(hos_eks_mbr_t), eks, sizeof(hos_eks_mbr_t));
@ -646,7 +646,7 @@ try_load:
// Read the correct keyblob for older HOS versions. // Read the correct keyblob for older HOS versions.
if (ctxt->pkg1_id->kb <= HOS_KB_VERSION_600) if (ctxt->pkg1_id->kb <= HOS_KB_VERSION_600)
{ {
ctxt->keyblob = (u8 *)calloc(EMMC_BLOCKSIZE, 1); ctxt->keyblob = (u8 *)zalloc(EMMC_BLOCKSIZE);
emummc_storage_read(PKG1_HOS_KEYBLOBS_OFFSET / EMMC_BLOCKSIZE + ctxt->pkg1_id->kb, 1, ctxt->keyblob); emummc_storage_read(PKG1_HOS_KEYBLOBS_OFFSET / EMMC_BLOCKSIZE + ctxt->pkg1_id->kb, 1, ctxt->keyblob);
} }

View file

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2018 naehrwert * Copyright (c) 2018 naehrwert
* Copyright (c) 2018-2021 CTCaer * Copyright (c) 2018-2024 CTCaer
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@ -122,27 +122,28 @@ int config_kip1patch(launch_ctxt_t *ctxt, const char *value)
if (value == NULL) if (value == NULL)
return 0; return 0;
int valueLen = strlen(value); int len = strlen(value);
if (!valueLen) if (!len)
return 0; return 0;
if (ctxt->kip1_patches == NULL) if (ctxt->kip1_patches == NULL)
{ {
ctxt->kip1_patches = malloc(valueLen + 1); ctxt->kip1_patches = malloc(len + 1);
memcpy(ctxt->kip1_patches, value, valueLen); memcpy(ctxt->kip1_patches, value, len);
ctxt->kip1_patches[valueLen] = 0; ctxt->kip1_patches[len] = 0;
} }
else else
{ {
char *oldAlloc = ctxt->kip1_patches; char *old_addr = ctxt->kip1_patches;
int oldSize = strlen(oldAlloc); int old_len = strlen(old_addr);
ctxt->kip1_patches = malloc(oldSize + 1 + valueLen + 1);
memcpy(ctxt->kip1_patches, oldAlloc, oldSize); ctxt->kip1_patches = malloc(old_len + 1 + len + 1);
free(oldAlloc); memcpy(ctxt->kip1_patches, old_addr, old_len);
oldAlloc = NULL; free(old_addr);
ctxt->kip1_patches[oldSize++] = ',';
memcpy(&ctxt->kip1_patches[oldSize], value, valueLen); ctxt->kip1_patches[old_len++] = ',';
ctxt->kip1_patches[oldSize + valueLen] = 0; memcpy(&ctxt->kip1_patches[old_len], value, len);
ctxt->kip1_patches[old_len + len] = 0;
} }
return 1; return 1;
} }
@ -220,7 +221,7 @@ static int _config_exo_user_pmu_access(launch_ctxt_t *ctxt, const char *value)
static int _config_exo_usb3_force(launch_ctxt_t *ctxt, const char *value) static int _config_exo_usb3_force(launch_ctxt_t *ctxt, const char *value)
{ {
// Override key found. // Override key found.
ctxt->exo_ctx.usb3_force = calloc(sizeof(bool), 1); ctxt->exo_ctx.usb3_force = zalloc(sizeof(bool));
if (*value == '1') if (*value == '1')
{ {
@ -233,7 +234,7 @@ static int _config_exo_usb3_force(launch_ctxt_t *ctxt, const char *value)
static int _config_exo_cal0_blanking(launch_ctxt_t *ctxt, const char *value) static int _config_exo_cal0_blanking(launch_ctxt_t *ctxt, const char *value)
{ {
// Override key found. // Override key found.
ctxt->exo_ctx.cal0_blank = calloc(sizeof(bool), 1); ctxt->exo_ctx.cal0_blank = zalloc(sizeof(bool));
if (*value == '1') if (*value == '1')
{ {
@ -246,7 +247,7 @@ static int _config_exo_cal0_blanking(launch_ctxt_t *ctxt, const char *value)
static int _config_exo_cal0_writes_enable(launch_ctxt_t *ctxt, const char *value) static int _config_exo_cal0_writes_enable(launch_ctxt_t *ctxt, const char *value)
{ {
// Override key found. // Override key found.
ctxt->exo_ctx.cal0_allow_writes_sys = calloc(sizeof(bool), 1); ctxt->exo_ctx.cal0_allow_writes_sys = zalloc(sizeof(bool));
if (*value == '1') if (*value == '1')
{ {

View file

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2018 naehrwert * Copyright (c) 2018 naehrwert
* Copyright (c) 2018-2023 CTCaer * Copyright (c) 2018-2024 CTCaer
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@ -77,7 +77,7 @@ static void parse_external_kip_patches()
if (ini_patch_parse(&ini_kip_sections, "bootloader/patches.ini")) if (ini_patch_parse(&ini_kip_sections, "bootloader/patches.ini"))
{ {
// Copy ids into a new patchset. // Copy ids into a new patchset.
_kip_id_sets = calloc(sizeof(kip1_id_t), 256); // Max 256 kip ids. _kip_id_sets = zalloc(sizeof(kip1_id_t) * 256); // Max 256 kip ids.
memcpy(_kip_id_sets, _kip_ids, sizeof(_kip_ids)); memcpy(_kip_id_sets, _kip_ids, sizeof(_kip_ids));
// Parse patchsets and glue them together. // Parse patchsets and glue them together.
@ -109,12 +109,12 @@ static void parse_external_kip_patches()
{ {
curr_kip->name = ini_psec->name; curr_kip->name = ini_psec->name;
memcpy(curr_kip->hash, ini_psec->hash, 8); memcpy(curr_kip->hash, ini_psec->hash, 8);
curr_kip->patchset = calloc(sizeof(kip1_patchset_t), 1); curr_kip->patchset = zalloc(sizeof(kip1_patchset_t));
_kip_id_sets_cnt++; _kip_id_sets_cnt++;
} }
kip1_patchset_t *patchsets = (kip1_patchset_t *)calloc(sizeof(kip1_patchset_t), 16); // Max 16 patchsets per kip. kip1_patchset_t *patchsets = (kip1_patchset_t *)zalloc(sizeof(kip1_patchset_t) * 16); // Max 16 patchsets per kip.
u32 curr_patchset_idx; u32 curr_patchset_idx;
for (curr_patchset_idx = 0; curr_kip->patchset[curr_patchset_idx].name != NULL; curr_patchset_idx++) for (curr_patchset_idx = 0; curr_kip->patchset[curr_patchset_idx].name != NULL; curr_patchset_idx++)
@ -128,7 +128,7 @@ static void parse_external_kip_patches()
u32 curr_patch_idx = 0; u32 curr_patch_idx = 0;
// Parse patches and glue them together to a patchset. // Parse patches and glue them together to a patchset.
kip1_patch_t *patches = calloc(sizeof(kip1_patch_t), 32); // Max 32 patches per set. kip1_patch_t *patches = zalloc(sizeof(kip1_patch_t) * 32); // Max 32 patches per set.
LIST_FOREACH_ENTRY(ini_patchset_t, pt, &ini_psec->pts, link) LIST_FOREACH_ENTRY(ini_patchset_t, pt, &ini_psec->pts, link)
{ {
if (first_ext_patch) if (first_ext_patch)
@ -142,7 +142,7 @@ static void parse_external_kip_patches()
// New patchset name found, create a new set. // New patchset name found, create a new set.
curr_patchset_idx++; curr_patchset_idx++;
curr_patch_idx = 0; curr_patch_idx = 0;
patches = calloc(sizeof(kip1_patch_t), 32); // Max 32 patches per set. patches = zalloc(sizeof(kip1_patch_t) * 32); // Max 32 patches per set.
patchsets[curr_patchset_idx].name = pt->name; patchsets[curr_patchset_idx].name = pt->name;
patchsets[curr_patchset_idx].patches = patches; patchsets[curr_patchset_idx].patches = patches;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019-2022 CTCaer * Copyright (c) 2019-2024 CTCaer
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@ -80,7 +80,7 @@ static ini_kip_sec_t *_ini_create_kip_section(link_t *dst, ini_kip_sec_t *ksec,
// Calculate total allocation size. // Calculate total allocation size.
u32 len = strlen(name); u32 len = strlen(name);
char *buf = calloc(sizeof(ini_kip_sec_t) + len + 1, 1); char *buf = zalloc(sizeof(ini_kip_sec_t) + len + 1);
ksec = (ini_kip_sec_t *)buf; ksec = (ini_kip_sec_t *)buf;
u32 i = _find_patch_section_name(name, len, ':') + 1; u32 i = _find_patch_section_name(name, len, ':') + 1;
@ -132,7 +132,7 @@ int ini_patch_parse(link_t *dst, char *ini_path)
u32 pos = _find_patch_section_name(lbuf, lblen, '='); u32 pos = _find_patch_section_name(lbuf, lblen, '=');
// Calculate total allocation size. // Calculate total allocation size.
char *buf = calloc(sizeof(ini_patchset_t) + strlen(&lbuf[1]) + 1, 1); char *buf = zalloc(sizeof(ini_patchset_t) + strlen(&lbuf[1]) + 1);
ini_patchset_t *pt = (ini_patchset_t *)buf; ini_patchset_t *pt = (ini_patchset_t *)buf;
// Set patch name. // Set patch name.

View file

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2018 naehrwert * Copyright (c) 2018 naehrwert
* *
* Copyright (c) 2018-2023 CTCaer * Copyright (c) 2018-2024 CTCaer
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@ -767,7 +767,7 @@ static void _check_for_updated_bootloader()
_launch_payload("bootloader/update.bin", true, false); _launch_payload("bootloader/update.bin", true, false);
else else
{ {
u8 *buf = calloc(0x200, 1); u8 *buf = zalloc(0x200);
is_ipl_updated(buf, "bootloader/update.bin", true); is_ipl_updated(buf, "bootloader/update.bin", true);
free(buf); free(buf);
} }
@ -1236,7 +1236,7 @@ static void _check_low_battery()
u8 *battery_icon = malloc(0x95A); // 21x38x3 u8 *battery_icon = malloc(0x95A); // 21x38x3
u8 *charging_icon = malloc(0x2F4); // 21x12x3 u8 *charging_icon = malloc(0x2F4); // 21x12x3
u8 *no_charging_icon = calloc(0x2F4, 1); u8 *no_charging_icon = zalloc(0x2F4);
memcpy(charging_icon, battery_res, 0x2F4); memcpy(charging_icon, battery_res, 0x2F4);
memcpy(battery_icon, battery_res + 0x2F4, 0x95A); memcpy(battery_icon, battery_res + 0x2F4, 0x95A);

View file

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2018 naehrwert * Copyright (c) 2018 naehrwert
* Copyright (c) 2018 Rajko Stojadinovic * Copyright (c) 2018 Rajko Stojadinovic
* Copyright (c) 2018-2022 CTCaer * Copyright (c) 2018-2024 CTCaer
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@ -40,7 +40,7 @@ extern char *emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_s
static void _get_valid_partition(u32 *sector_start, u32 *sector_size, u32 *part_idx, bool backup) static void _get_valid_partition(u32 *sector_start, u32 *sector_size, u32 *part_idx, bool backup)
{ {
sd_mount(); sd_mount();
mbr_t *mbr = (mbr_t *)calloc(sizeof(mbr_t), 1); mbr_t *mbr = (mbr_t *)zalloc(sizeof(mbr_t));
sdmmc_storage_read(&sd_storage, 0, 1, mbr); sdmmc_storage_read(&sd_storage, 0, 1, mbr);
*part_idx = 0; *part_idx = 0;
@ -90,7 +90,7 @@ static void _get_valid_partition(u32 *sector_start, u32 *sector_size, u32 *part_
// Get emuMMC GPP size. // Get emuMMC GPP size.
if (backup && *part_idx && *sector_size) if (backup && *part_idx && *sector_size)
{ {
gpt_t *gpt = (gpt_t *)calloc(sizeof(gpt_t), 1); gpt_t *gpt = (gpt_t *)zalloc(sizeof(gpt_t));
sdmmc_storage_read(&sd_storage, *sector_start + 0x4001, 1, gpt); sdmmc_storage_read(&sd_storage, *sector_start + 0x4001, 1, gpt);
u32 new_size = gpt->header.alt_lba + 1; u32 new_size = gpt->header.alt_lba + 1;

View file

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2018 naehrwert * Copyright (c) 2018 naehrwert
* Copyright (c) 2018 Rajko Stojadinovic * Copyright (c) 2018 Rajko Stojadinovic
* Copyright (c) 2018-2023 CTCaer * Copyright (c) 2018-2024 CTCaer
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@ -705,7 +705,7 @@ static int _dump_emummc_raw_part(emmc_tool_gui_t *gui, int active_part, int part
// Read MBR, GPT and backup GPT. // Read MBR, GPT and backup GPT.
mbr_t mbr; mbr_t mbr;
gpt_t *gpt = calloc(1, sizeof(gpt_t)); gpt_t *gpt = zalloc(sizeof(gpt_t));
gpt_header_t gpt_hdr_backup; gpt_header_t gpt_hdr_backup;
sdmmc_storage_read(&emmc_storage, 0, 1, &mbr); sdmmc_storage_read(&emmc_storage, 0, 1, &mbr);
sdmmc_storage_read(&emmc_storage, 1, sizeof(gpt_t) >> 9, gpt); sdmmc_storage_read(&emmc_storage, 1, sizeof(gpt_t) >> 9, gpt);

View file

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2018 naehrwert * Copyright (c) 2018 naehrwert
* Copyright (c) 2018-2023 CTCaer * Copyright (c) 2018-2024 CTCaer
* Copyright (c) 2018 balika011 * Copyright (c) 2018 balika011
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
@ -1107,7 +1107,7 @@ static lv_res_t _create_mbox_emmc_sandisk_report(lv_obj_t * btn)
lv_mbox_set_text(mbox, "#C7EA46 Sandisk Device Report#"); lv_mbox_set_text(mbox, "#C7EA46 Sandisk Device Report#");
u8 *buf = calloc(EMMC_BLOCKSIZE, 1); u8 *buf = zalloc(EMMC_BLOCKSIZE);
char *txt_buf = (char *)malloc(SZ_32K); char *txt_buf = (char *)malloc(SZ_32K);
char *txt_buf2 = (char *)malloc(SZ_32K); char *txt_buf2 = (char *)malloc(SZ_32K);
txt_buf[0] = 0; txt_buf[0] = 0;

View file

@ -1145,10 +1145,10 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
char path[128]; char path[128];
u8 kb = 0; u8 kb = 0;
u8 *pkg1 = (u8 *)calloc(1, SZ_256K); u8 *pkg1 = (u8 *)zalloc(SZ_256K);
u8 *warmboot = (u8 *)calloc(1, SZ_256K); u8 *warmboot = (u8 *)zalloc(SZ_256K);
u8 *secmon = (u8 *)calloc(1, SZ_256K); u8 *secmon = (u8 *)zalloc(SZ_256K);
u8 *loader = (u8 *)calloc(1, SZ_256K); u8 *loader = (u8 *)zalloc(SZ_256K);
u8 *pkg2 = NULL; u8 *pkg2 = NULL;
char *txt_buf = (char *)malloc(SZ_16K); char *txt_buf = (char *)malloc(SZ_16K);
@ -1207,7 +1207,7 @@ static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn)
tsec_ctxt.pkg11_off = pkg1_id->pkg11_off; tsec_ctxt.pkg11_off = pkg1_id->pkg11_off;
// Read keyblob. // Read keyblob.
u8 *keyblob = (u8 *)calloc(EMMC_BLOCKSIZE, 1); u8 *keyblob = (u8 *)zalloc(EMMC_BLOCKSIZE);
sdmmc_storage_read(&emmc_storage, HOS_KEYBLOBS_OFFSET / EMMC_BLOCKSIZE + kb, 1, keyblob); sdmmc_storage_read(&emmc_storage, HOS_KEYBLOBS_OFFSET / EMMC_BLOCKSIZE + kb, 1, keyblob);
// Decrypt. // Decrypt.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019-2022 CTCaer * Copyright (c) 2019-2024 CTCaer
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@ -345,7 +345,7 @@ static void _prepare_and_flash_mbr_gpt()
if (part_info.and_size) if (part_info.and_size)
{ {
gpt_t *gpt = calloc(1, sizeof(gpt_t)); gpt_t *gpt = zalloc(sizeof(gpt_t));
gpt_header_t gpt_hdr_backup = { 0 }; gpt_header_t gpt_hdr_backup = { 0 };
// Set GPT protective partition in MBR. // Set GPT protective partition in MBR.
@ -768,7 +768,7 @@ exit:
static u32 _get_available_l4t_partition() static u32 _get_available_l4t_partition()
{ {
mbr_t mbr = { 0 }; mbr_t mbr = { 0 };
gpt_t *gpt = calloc(1, sizeof(gpt_t)); gpt_t *gpt = zalloc(sizeof(gpt_t));
memset(&l4t_flash_ctxt, 0, sizeof(l4t_flasher_ctxt_t)); memset(&l4t_flash_ctxt, 0, sizeof(l4t_flasher_ctxt_t));
@ -815,7 +815,7 @@ static u32 _get_available_l4t_partition()
static bool _get_available_android_partition() static bool _get_available_android_partition()
{ {
gpt_t *gpt = calloc(1, sizeof(gpt_t)); gpt_t *gpt = zalloc(sizeof(gpt_t));
// Read main GPT. // Read main GPT.
sdmmc_storage_read(&sd_storage, 1, sizeof(gpt_t) >> 9, gpt); sdmmc_storage_read(&sd_storage, 1, sizeof(gpt_t) >> 9, gpt);
@ -1007,7 +1007,7 @@ static lv_res_t _action_flash_android_data(lv_obj_t * btns, const char * txt)
// Flash Android components. // Flash Android components.
char path[128]; char path[128];
gpt_t *gpt = calloc(1, sizeof(gpt_t)); gpt_t *gpt = zalloc(sizeof(gpt_t));
char *txt_buf = malloc(SZ_4K); char *txt_buf = malloc(SZ_4K);
lv_obj_t *dark_bg = lv_obj_create(lv_scr_act(), NULL); lv_obj_t *dark_bg = lv_obj_create(lv_scr_act(), NULL);
@ -1077,7 +1077,7 @@ static lv_res_t _action_flash_android_data(lv_obj_t * btns, const char * txt)
if (file_size % 0x200) if (file_size % 0x200)
{ {
file_size = ALIGN(file_size, 0x200); file_size = ALIGN(file_size, 0x200);
u8 *buf_tmp = calloc(file_size, 1); u8 *buf_tmp = zalloc(file_size);
memcpy(buf_tmp, buf, file_size); memcpy(buf_tmp, buf, file_size);
free(buf); free(buf);
buf = buf_tmp; buf = buf_tmp;
@ -1141,7 +1141,7 @@ boot_img_not_found:
if (file_size % 0x200) if (file_size % 0x200)
{ {
file_size = ALIGN(file_size, 0x200); file_size = ALIGN(file_size, 0x200);
u8 *buf_tmp = calloc(file_size, 1); u8 *buf_tmp = zalloc(file_size);
memcpy(buf_tmp, buf, file_size); memcpy(buf_tmp, buf, file_size);
free(buf); free(buf);
buf = buf_tmp; buf = buf_tmp;
@ -1203,7 +1203,7 @@ recovery_not_found:
if (file_size % 0x200) if (file_size % 0x200)
{ {
file_size = ALIGN(file_size, 0x200); file_size = ALIGN(file_size, 0x200);
u8 *buf_tmp = calloc(file_size, 1); u8 *buf_tmp = zalloc(file_size);
memcpy(buf_tmp, buf, file_size); memcpy(buf_tmp, buf, file_size);
free(buf); free(buf);
buf = buf_tmp; buf = buf_tmp;
@ -2228,7 +2228,7 @@ static lv_res_t _action_fix_mbr(lv_obj_t *btn)
lv_label_set_recolor(lbl_status, true); lv_label_set_recolor(lbl_status, true);
mbr_t mbr[2] = { 0 }; mbr_t mbr[2] = { 0 };
gpt_t *gpt = calloc(1, sizeof(gpt_t)); gpt_t *gpt = zalloc(sizeof(gpt_t));
gpt_header_t gpt_hdr_backup = { 0 }; gpt_header_t gpt_hdr_backup = { 0 };
bool has_mbr_attributes = false; bool has_mbr_attributes = false;
@ -2279,7 +2279,7 @@ static lv_res_t _action_fix_mbr(lv_obj_t *btn)
LIST_INIT(gpt_parsed); LIST_INIT(gpt_parsed);
for (u32 i = 0; i < gpt->header.num_part_ents; i++) for (u32 i = 0; i < gpt->header.num_part_ents; i++)
{ {
emmc_part_t *part = (emmc_part_t *)calloc(sizeof(emmc_part_t), 1); emmc_part_t *part = (emmc_part_t *)zalloc(sizeof(emmc_part_t));
if (gpt->entries[i].lba_start < gpt->header.first_use_lba) if (gpt->entries[i].lba_start < gpt->header.first_use_lba)
continue; continue;

View file

@ -210,7 +210,7 @@ static void _hos_eks_get()
if (!h_cfg.eks) if (!h_cfg.eks)
{ {
// Read EKS blob. // Read EKS blob.
u8 *mbr = calloc(SD_BLOCKSIZE, 1); u8 *mbr = zalloc(SD_BLOCKSIZE);
if (!hos_eks_rw_try(mbr, false)) if (!hos_eks_rw_try(mbr, false))
goto out; goto out;
@ -240,7 +240,7 @@ static void _hos_eks_save()
bool new_eks = false; bool new_eks = false;
if (!h_cfg.eks) if (!h_cfg.eks)
{ {
h_cfg.eks = calloc(SD_BLOCKSIZE, 1); h_cfg.eks = zalloc(SD_BLOCKSIZE);
new_eks = true; new_eks = true;
} }
@ -248,7 +248,7 @@ static void _hos_eks_save()
if (h_cfg.eks->enabled != HOS_EKS_TSEC_VER) if (h_cfg.eks->enabled != HOS_EKS_TSEC_VER)
{ {
// Read EKS blob. // Read EKS blob.
u8 *mbr = calloc(SD_BLOCKSIZE, 1); u8 *mbr = zalloc(SD_BLOCKSIZE);
if (!hos_eks_rw_try(mbr, false)) if (!hos_eks_rw_try(mbr, false))
{ {
if (new_eks) if (new_eks)
@ -261,7 +261,7 @@ static void _hos_eks_save()
} }
// Get keys. // Get keys.
u8 *keys = (u8 *)calloc(SZ_4K, 2); u8 *keys = (u8 *)calloc(2, SZ_4K);
se_get_aes_keys(keys + SZ_4K, keys, SE_KEY_128_SIZE); se_get_aes_keys(keys + SZ_4K, keys, SE_KEY_128_SIZE);
// Set magic and personalized info. // Set magic and personalized info.
@ -275,7 +275,7 @@ static void _hos_eks_save()
memcpy(h_cfg.eks->troot_dev, keys + 11 * SE_KEY_128_SIZE, SE_KEY_128_SIZE); memcpy(h_cfg.eks->troot_dev, keys + 11 * SE_KEY_128_SIZE, SE_KEY_128_SIZE);
// Encrypt EKS blob. // Encrypt EKS blob.
u8 *eks = calloc(SD_BLOCKSIZE, 1); u8 *eks = zalloc(SD_BLOCKSIZE);
memcpy(eks, h_cfg.eks, sizeof(hos_eks_mbr_t)); memcpy(eks, h_cfg.eks, sizeof(hos_eks_mbr_t));
se_aes_crypt_ecb(14, ENCRYPT, eks, sizeof(hos_eks_mbr_t), eks, sizeof(hos_eks_mbr_t)); se_aes_crypt_ecb(14, ENCRYPT, eks, sizeof(hos_eks_mbr_t), eks, sizeof(hos_eks_mbr_t));
@ -302,7 +302,7 @@ void hos_eks_clear(u32 kb)
if (h_cfg.eks->enabled) if (h_cfg.eks->enabled)
{ {
// Read EKS blob. // Read EKS blob.
u8 *mbr = calloc(SD_BLOCKSIZE, 1); u8 *mbr = zalloc(SD_BLOCKSIZE);
if (!hos_eks_rw_try(mbr, false)) if (!hos_eks_rw_try(mbr, false))
goto out; goto out;
@ -310,7 +310,7 @@ void hos_eks_clear(u32 kb)
h_cfg.eks->enabled = 0; h_cfg.eks->enabled = 0;
// Encrypt EKS blob. // Encrypt EKS blob.
u8 *eks = calloc(SD_BLOCKSIZE, 1); u8 *eks = zalloc(SD_BLOCKSIZE);
memcpy(eks, h_cfg.eks, sizeof(hos_eks_mbr_t)); memcpy(eks, h_cfg.eks, sizeof(hos_eks_mbr_t));
se_aes_crypt_ecb(14, ENCRYPT, eks, sizeof(hos_eks_mbr_t), eks, sizeof(hos_eks_mbr_t)); se_aes_crypt_ecb(14, ENCRYPT, eks, sizeof(hos_eks_mbr_t), eks, sizeof(hos_eks_mbr_t));

View file

@ -21,132 +21,3 @@
.nosigchk=0:0x194A0:0x4:BA090094,E0031F2A .nosigchk=0:0x194A0:0x4:BA090094,E0031F2A
.nosigchk=0:0x3A79C:0x4:E0060036,1F2003D5 .nosigchk=0:0x3A79C:0x4:E0060036,1F2003D5
#FS Patches for 2.0.0
[FS:cd7bbe18d6130b28]
.nosigchk=0:0x15DF4:0x4:BC0A0094,E0031F2A
.nosigchk=0:0x3F720:0x4:00060036,1F2003D5
#FS Patches for 2.0.0 exfat
[FS:e76692dfaa0420e9]
.nosigchk=0:0x15DF4:0x4:BC0A0094,E0031F2A
.nosigchk=0:0x3F720:0x4:00060036,1F2003D5
#FS Patches for 2.1.0
[FS:0d7005627b07767c]
.nosigchk=0:0x15F64:0x4:DF0A0094,E0031F2A
.nosigchk=0:0x3FAF8:0x4:00060036,1F2003D5
#FS Patches for 2.1.0 exfat
[FS:dbd85fcacc193da8]
.nosigchk=0:0x15F64:0x4:DF0A0094,E0031F2A
.nosigchk=0:0x3FAF8:0x4:00060036,1F2003D5
#FS Patches for 3.0.0
[FS:a86da5e87ef1097b]
.nosigchk=0:0x18E24:0x4:520C0094,E0031F2A
.nosigchk=0:0x49EC8:0x4:40040036,1F2003D5
#FS Patches for 3.0.0 exfat
[FS:981c57e7f02f70f7]
.nosigchk=0:0x18E24:0x4:520C0094,E0031F2A
.nosigchk=0:0x49EC8:0x4:40040036,1F2003D5
#FS Patches for 3.0.1
[FS:57397c063f10b631]
.nosigchk=0:0x18E90:0x4:520C0094,E0031F2A
.nosigchk=0:0x49F34:0x4:E0030036,1F2003D5
#FS Patches for 3.0.1 exfat
[FS:073099d7c6ad7d89]
.nosigchk=0:0x18E90:0x4:520C0094,E0031F2A
.nosigchk=0:0x49F34:0x4:E0030036,1F2003D5
#FS Patches for 4.0.0
[FS:06e90719595a010c]
.nosigchk=0:0x1C4FC:0x4:3C2F0094,E0031F2A
.nosigchk=0:0x57934:0x4:E0020036,1F2003D5
#FS Patches for 4.0.0 exfat
[FS:549b0f8d6f72c4e9]
.nosigchk=0:0x1C4FC:0x4:3C2F0094,E0031F2A
.nosigchk=0:0x57934:0x4:E0020036,1F2003D5
#FS Patches for 4.1.0
[FS:8096af7c6a35aa82]
.nosigchk=0:0x1C4FC:0x4:3C2F0094,E0031F2A
.nosigchk=0:0x57934:0x4:E0020036,1F2003D5
#FS Patches for 4.1.0 exfat
[FS:02d5abaafd20c8b0]
.nosigchk=0:0x1C4FC:0x4:3C2F0094,E0031F2A
.nosigchk=0:0x57934:0x4:E0020036,1F2003D5
#FS Patches for 5.0.0
[FS:a6f27ad9ac7c73ad]
.nosigchk=0:0x22DDC:0x4:7D3E0094,E0031F2A
.nosigchk=0:0x7D490:0x4:40030036,1F2003D5
#FS Patches for 5.0.0 exfat
[FS:ce3ecba2f2f062f5]
.nosigchk=0:0x22DDC:0x4:7D3E0094,E0031F2A
.nosigchk=0:0x7D490:0x4:40030036,1F2003D5
#FS Patches for 5.1.0
[FS:76f87402c9387c0f]
.nosigchk=0:0x22E0C:0x4:853E0094,E0031F2A
.nosigchk=0:0x7D860:0x4:40030036,1F2003D5
#FS Patches for 5.1.0 exfat
[FS:10b2d81605488599]
.nosigchk=0:0x22E0C:0x4:853E0094,E0031F2A
.nosigchk=0:0x7D860:0x4:40030036,1F2003D5
#FS Patches for 6.0.0 - 4
[FS:1b82cb221867cb52]
.nosigchk=0:0x712A8:0x4:8E3E0094,E0031F2A
.nosigchk=0:0xEB08C:0x4:C0030036,1F2003D5
#FS Patches for 6.0.0 - 4 exfat
[FS:966add3d20b62713]
.nosigchk=0:0x7C9A8:0x4:8E3E0094,E0031F2A
.nosigchk=0:0xF678C:0x4:C0030036,1F2003D5
#FS Patches for 6.0.0 - 5
[FS:3a574d436186191d]
.nosigchk=0:0x712A8:0x4:8E3E0094,E0031F2A
.nosigchk=0:0xEB08C:0x4:C0030036,1F2003D5
#FS Patches for 6.0.0 - 5 exfat
[FS:330553f6b5fb55c4]
.nosigchk=0:0x7C9A8:0x4:8E3E0094,E0031F2A
.nosigchk=0:0xF678C:0x4:C0030036,1F2003D5
#FS Patches for 7.0.0
[FS:2ADBE97E9B5F4177]
.nosigchk=0:0x74A2C:0x4:31430094,E0031F2A
.nosigchk=0:0xF25E4:0x4:C0030036,1F2003D5
#FS Patches for 7.0.0 exfat
[FS:2CCE659CEC536A8E]
.nosigchk=0:0x7FFDC:0x4:31430094,E0031F2A
.nosigchk=0:0xFDB94:0x4:C0030036,1F2003D5
#FS Patches for 8.0.0
[FS:B2F5176B3548364D]
.nosigchk=0:0x7630C:0x4:51440094,E0031F2A
.nosigchk=0:0xF49A4:0x4:C0030036,1F2003D5
#FS Patches for 8.0.0 exfat
[FS:DBD941C0C53C52CC]
.nosigchk=0:0x818BC:0x4:51440094,E0031F2A
.nosigchk=0:0xFFF54:0x4:C0030036,1F2003D5
#FS Patches for 8.1.0
[FS:6B09B67B29C02024]
.nosigchk=0:0x7630C:0x4:51440094,E0031F2A
.nosigchk=0:0xF49A4:0x4:C0030036,1F2003D5
#FS Patches for 8.1.0 exfat
[FS:B4CAE1F24965D92E]
.nosigchk=0:0x818BC:0x4:51440094,E0031F2A
.nosigchk=0:0xFFF54:0x4:C0030036,1F2003D5