From 46038032a495703ad5d4ccad90d62d53d92d2fa1 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Wed, 17 Mar 2021 09:23:13 +0200 Subject: [PATCH] bdk: make sure that boot storage has the correct size --- README.md | 2 +- bdk/utils/dirlist.c | 10 +++++----- bdk/utils/types.h | 4 ++++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 550e957..84bae94 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ You can find a template [Here](./res/hekate_ipl_template.ini) | kip1patch=patchname | Enables a kip1 patch. Specify with multiple lines and/or as CSV. If not found, an error will show up | | fullsvcperm=1 | Disables SVC verification (full services permission) | | debugmode=1 | Enables Debug mode. Obsolete when used with exosphere as secmon. | -| atmosphere=1 | Enables Atmosphère patching. | +| atmosphere=1 | Enables Atmosphère patching. Not needed when `fss0` is used. | | emupath={SD folder} | Forces emuMMC to use the selected one. (=emuMMC/RAW1, =emuMMC/SD00, etc). emuMMC must be created by hekate because it uses the raw_based/file_based files. | | emummcforce=1 | Forces the use of emuMMC. If emummc.ini is disabled or not found, then it causes an error. | | emummc_force_disable=1 | Disables emuMMC, if it's enabled. | diff --git a/bdk/utils/dirlist.c b/bdk/utils/dirlist.c index 5732683..3b09d1d 100644 --- a/bdk/utils/dirlist.c +++ b/bdk/utils/dirlist.c @@ -21,16 +21,16 @@ #include #include +#define MAX_ENTRIES 64 + char *dirlist(const char *directory, const char *pattern, bool includeHiddenFiles, bool parse_dirs) { - u8 max_entries = 61; - int res = 0; u32 i = 0, j = 0, k = 0; DIR dir; FILINFO fno; - char *dir_entries = (char *)calloc(max_entries, 256); + char *dir_entries = (char *)calloc(MAX_ENTRIES, 256); char *temp = (char *)calloc(1, 256); if (!pattern && !f_opendir(&dir, directory)) @@ -49,7 +49,7 @@ char *dirlist(const char *directory, const char *pattern, bool includeHiddenFile { strcpy(dir_entries + (k * 256), fno.fname); k++; - if (k > (max_entries - 1)) + if (k > (MAX_ENTRIES - 1)) break; } } @@ -64,7 +64,7 @@ char *dirlist(const char *directory, const char *pattern, bool includeHiddenFile { strcpy(dir_entries + (k * 256), fno.fname); k++; - if (k > (max_entries - 1)) + if (k > (MAX_ENTRIES - 1)) break; } res = f_findnext(&dir, &fno); diff --git a/bdk/utils/types.h b/bdk/utils/types.h index 8e476fd..2059bab 100644 --- a/bdk/utils/types.h +++ b/bdk/utils/types.h @@ -18,6 +18,8 @@ #ifndef _TYPES_H_ #define _TYPES_H_ +#include + #define NULL ((void *)0) #define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) @@ -116,6 +118,8 @@ typedef struct __attribute__((__packed__)) _boot_cfg_t }; } boot_cfg_t; +static_assert(sizeof(boot_cfg_t) == 0x84, "Boot CFG size is wrong!"); + typedef struct __attribute__((__packed__)) _ipl_ver_meta_t { u32 magic;