diff --git a/arm9/source/common/ui.c b/arm9/source/common/ui.c index 33b5a1d..bebe501 100644 --- a/arm9/source/common/ui.c +++ b/arm9/source/common/ui.c @@ -548,13 +548,13 @@ void ResizeString(char* dest, const char* orig, int nlength, int tpos, bool alig for (int i = 0; i < nlength || (orig[nsize] & 0xC0) == 0x80; nsize++) { if ((orig[nsize] & 0xC0) != 0x80) i++; } - snprintf(dest, nsize + 1, "%-*.*s", nsize, nsize, orig); + snprintf(dest, UTF_BUFFER_BYTESIZE(nlength), "%-*.*s", nsize, nsize, orig); } else { int nsize = 0; for (int i = 0; i < nlength || (orig[nsize] & 0xC0) == 0x80; nsize++) { if ((orig[nsize] & 0xC0) != 0x80) i++; } - snprintf(dest, nsize + 1, "%*.*s", nsize, nsize, orig); + snprintf(dest, UTF_BUFFER_BYTESIZE(nlength), "%*.*s", nsize, nsize, orig); } } @@ -570,11 +570,6 @@ void TruncateString(char* dest, const char* orig, int nlength, int tpos) { } else if ((nlength <= 3) || (nlength >= olength)) { strcpy(dest, orig); } else { - int nsize = 0; - for (int i = 0; i < nlength || (orig[nsize] & 0xC0) == 0x80; nsize++) { - if ((orig[nsize] & 0xC0) != 0x80) i++; - } - if (tpos + 3 > nlength) tpos = nlength - 3; int tposStart = 0; @@ -587,7 +582,7 @@ void TruncateString(char* dest, const char* orig, int nlength, int tpos) { if ((orig[osize - 1 - tposEnd] & 0xC0) != 0x80) i++; } - snprintf(dest, nsize + 1, "%-.*s...%-.*s", tposStart, orig, tposEnd, orig + osize - tposEnd); + snprintf(dest, UTF_BUFFER_BYTESIZE(nlength), "%-.*s...%-.*s", tposStart, orig, tposEnd, orig + osize - tposEnd); } } @@ -887,7 +882,7 @@ u32 ShowFileScrollPrompt(u32 n, const DirEntry** options, bool hide_ext, const c char bytestr[16]; FormatBytes(bytestr, options[i]->size); - char content_str[64 * 4 + 1]; + char content_str[UTF_BUFFER_BYTESIZE(fname_len)]; char temp_str[256]; strncpy(temp_str, options[i]->name, 256); @@ -1286,8 +1281,8 @@ bool ShowProgress(u64 current, u64 total, const char* opstr) const u32 text_pos_y = bar_pos_y + bar_height + 2; u32 prog_width = ((total > 0) && (current <= total)) ? (current * (bar_width-4)) / total : 0; u32 prog_percent = ((total > 0) && (current <= total)) ? (current * 100) / total : 0; - char tempstr[256]; - char progstr[256]; + char tempstr[64]; + char progstr[UTF_BUFFER_BYTESIZE(64)]; static u64 last_msec_elapsed = 0; static u64 last_sec_remain = 0; diff --git a/arm9/source/common/ui.h b/arm9/source/common/ui.h index 00c625c..bfcd379 100644 --- a/arm9/source/common/ui.h +++ b/arm9/source/common/ui.h @@ -21,6 +21,9 @@ #define FONT_WIDTH_EXT GetFontWidth() #define FONT_HEIGHT_EXT GetFontHeight() +#define UTF_MAX_BYTES_PER_RUNE 4 +#define UTF_BUFFER_BYTESIZE(rune_count) (((rune_count) + 1) * UTF_MAX_BYTES_PER_RUNE) + #define TOP_SCREEN ((u16*)VRAM_TOP_LA) #define BOT_SCREEN ((u16*)VRAM_BOT_A) diff --git a/arm9/source/filesys/fsgame.c b/arm9/source/filesys/fsgame.c index c7fccbd..8a0f49f 100644 --- a/arm9/source/filesys/fsgame.c +++ b/arm9/source/filesys/fsgame.c @@ -34,7 +34,7 @@ bool GoodRenamer(DirEntry* entry, bool ask) { return false; if (ask) { // ask for confirmatiom - char oldname_tr[32 * 4 + 1]; + char oldname_tr[UTF_BUFFER_BYTESIZE(32)]; char newname_ww[256]; TruncateString(oldname_tr, entry->name, 32, 8); strncpy(newname_ww, goodname, 256); diff --git a/arm9/source/filesys/fsutil.c b/arm9/source/filesys/fsutil.c index c4708b7..f785bfe 100644 --- a/arm9/source/filesys/fsutil.c +++ b/arm9/source/filesys/fsutil.c @@ -127,7 +127,7 @@ bool FileUnlock(const char* path) { if (!(DriveType(path) & DRV_FAT)) return true; // can't really check this if ((res = fx_open(&file, path, FA_READ | FA_OPEN_EXISTING)) != FR_OK) { - char pathstr[32 * 4 + 1]; + char pathstr[UTF_BUFFER_BYTESIZE(32)]; TruncateString(pathstr, path, 32, 8); if (GetMountState() && (res == FR_LOCKED) && (ShowPrompt(true, "%s\nFile is currently mounted.\nUnmount to unlock?", pathstr))) { @@ -461,7 +461,7 @@ bool PathMoveCopyRec(char* dest, char* orig, u32* flags, bool move, u8* buffer, if (move && (to_virtual || fno.fattrib & AM_VRT)) return false; // trying to move a virtual file // path string (for output) - char deststr[36 * 4 + 1]; + char deststr[UTF_BUFFER_BYTESIZE(36)]; TruncateString(deststr, dest, 36, 8); // the copy process takes place here @@ -609,7 +609,7 @@ bool PathMoveCopy(const char* dest, const char* orig, u32* flags, bool move) { char lorig[256]; strncpy(ldest, dest, 256); strncpy(lorig, orig, 256); - char deststr[36 * 4 + 1]; + char deststr[UTF_BUFFER_BYTESIZE(36)]; TruncateString(deststr, ldest, 36, 8); // moving only for regular FAT drives (= not alias drives) @@ -749,8 +749,8 @@ bool PathCopy(const char* destdir, const char* orig, u32* flags) { return false; snprintf(dest, 255, "%s/%s", destdir, dvfile.name); } else if (osize < dvfile.size) { // if origin is smaller than destination... - char deststr[36 * 4 + 1]; - char origstr[36 * 4 + 1]; + char deststr[UTF_BUFFER_BYTESIZE(36)]; + char origstr[UTF_BUFFER_BYTESIZE(36)]; char osizestr[32]; char dsizestr[32]; TruncateString(deststr, dest, 36, 8); @@ -822,7 +822,7 @@ bool FileSelectorWorker(char* result, const char* text, const char* path, const GetDirContents(contents, path_local); while (pos < contents->n_entries) { - char opt_names[_MAX_FS_OPT+1][32 * 4 + 1]; + char opt_names[_MAX_FS_OPT+1][UTF_BUFFER_BYTESIZE(32)]; DirEntry* res_entry[MAX_DIR_ENTRIES+1] = { NULL }; u32 n_opt = 0; for (; pos < contents->n_entries; pos++) { @@ -872,7 +872,7 @@ bool FileSelectorWorker(char* result, const char* text, const char* path, const } } if (!n_found) { // not a single matching entry found - char pathstr[32 * 4 + 1]; + char pathstr[UTF_BUFFER_BYTESIZE(32)]; TruncateString(pathstr, path_local, 32, 8); ShowPrompt(false, "%s\nNo usable entries found.", pathstr); return false; diff --git a/arm9/source/godmode.c b/arm9/source/godmode.c index 994b846..d7eb17a 100644 --- a/arm9/source/godmode.c +++ b/arm9/source/godmode.c @@ -51,7 +51,7 @@ typedef struct { u32 BootFirmHandler(const char* bootpath, bool verbose, bool delete) { - char pathstr[32 * 4 + 1]; + char pathstr[UTF_BUFFER_BYTESIZE(32)]; TruncateString(pathstr, bootpath, 32, 8); size_t firm_size = FileGetSize(bootpath); @@ -231,7 +231,7 @@ void DrawTopBar(const char* curr_path) { const u32 bartxt_start = (FONT_HEIGHT_EXT >= 10) ? 1 : (FONT_HEIGHT_EXT >= 7) ? 2 : 3; const u32 bartxt_x = 2; const u32 len_path = SCREEN_WIDTH_TOP - 120; - char tempstr[64 * 4]; + char tempstr[UTF_BUFFER_BYTESIZE(63)]; // top bar - current path DrawRectangle(TOP_SCREEN, 0, 0, SCREEN_WIDTH_TOP, 12, COLOR_TOP_BAR); @@ -282,7 +282,7 @@ void DrawUserInterface(const char* curr_path, DirEntry* curr_entry, u32 curr_pan const u32 instr_x = (SCREEN_WIDTH_MAIN - (34*FONT_WIDTH_EXT)) / 2; const u32 len_info = (SCREEN_WIDTH_MAIN - ((SCREEN_WIDTH_MAIN >= 400) ? 80 : 20)) / 2; const u32 str_len_info = min(63, len_info / FONT_WIDTH_EXT); - char tempstr[256]; + char tempstr[UTF_BUFFER_BYTESIZE(str_len_info)]; static u32 state_prev = 0xFFFFFFFF; u32 state_curr = @@ -386,12 +386,12 @@ void DrawDirContents(DirStruct* contents, u32 cursor, u32* scroll) { *scroll = (contents->n_entries > lines) ? contents->n_entries - lines : 0; for (u32 i = 0; pos_y < SCREEN_HEIGHT; i++) { - char tempstr[str_width * 4 + 1]; + char tempstr[UTF_BUFFER_BYTESIZE(str_width)]; u32 offset_i = *scroll + i; u32 color_font = COLOR_WHITE; if (offset_i < contents->n_entries) { DirEntry* curr_entry = &(contents->entry[offset_i]); - char namestr[str_width * 4 - 10 + 1]; + char namestr[UTF_BUFFER_BYTESIZE(str_width - 10)]; char bytestr[10 + 1]; color_font = (cursor != offset_i) ? COLOR_ENTRY(curr_entry) : COLOR_STD_FONT; FormatBytes(bytestr, curr_entry->size); @@ -846,7 +846,7 @@ u32 FileHexViewer(const char* path) { u32 ShaCalculator(const char* path, bool sha1) { const u8 hashlen = sha1 ? 20 : 32; u32 drvtype = DriveType(path); - char pathstr[32 * 4 + 1]; + char pathstr[UTF_BUFFER_BYTESIZE(32)]; u8 hash[32]; TruncateString(pathstr, path, 32, 8); if (!FileGetSha(path, hash, 0, 0, sha1)) { @@ -889,7 +889,7 @@ u32 ShaCalculator(const char* path, bool sha1) { } u32 CmacCalculator(const char* path) { - char pathstr[32 * 4 + 1]; + char pathstr[UTF_BUFFER_BYTESIZE(32)]; TruncateString(pathstr, path, 32, 8); if (IdentifyFileType(path) != GAME_CMD) { u8 cmac[16] __attribute__((aligned(4))); @@ -940,7 +940,7 @@ u32 StandardCopy(u32* cursor, u32* scroll) { DrawDirContents(current_dir, (*cursor = i), scroll); if (PathCopy(OUTPUT_PATH, path, &flags)) n_success++; else { // on failure: show error, break - char currstr[32 * 4 + 1]; + char currstr[UTF_BUFFER_BYTESIZE(32)]; TruncateString(currstr, path, 32, 12); ShowPrompt(false, "%s\nFailed copying item", currstr); break; @@ -949,7 +949,7 @@ u32 StandardCopy(u32* cursor, u32* scroll) { } if (n_success) ShowPrompt(false, "%lu items copied to %s", n_success, OUTPUT_PATH); } else { - char pathstr[32 * 4 + 1]; + char pathstr[UTF_BUFFER_BYTESIZE(32)]; TruncateString(pathstr, curr_entry->path, 32, 8); if (!PathCopy(OUTPUT_PATH, curr_entry->path, &flags)) ShowPrompt(false, "%s\nFailed copying item", pathstr); @@ -1151,7 +1151,7 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, PaneData** pan keyinstallable || bootable || scriptable || fontable || viewable || installable || agbexportable || agbimportable || cia_installable || tik_installable || tik_dumpable; - char pathstr[32 * 4 + 1]; + char pathstr[UTF_BUFFER_BYTESIZE(32)]; TruncateString(pathstr, file_path, 32, 8); char tidstr[32] = { 0 }; @@ -1305,7 +1305,7 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, PaneData** pan return 0; } else if (user_select == inject) { // -> inject data from clipboard - char origstr[18 * 4 + 1]; + char origstr[UTF_BUFFER_BYTESIZE(18)]; TruncateString(origstr, clipboard->entry[0].name, 18, 10); u64 offset = ShowHexPrompt(0, 8, "Inject data from %s?\nSpecify offset below.", origstr); if (offset != (u64) -1) { @@ -1483,7 +1483,7 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, PaneData** pan if (!(filetype & BIN_KEYDB) && (CryptGameFile(path, inplace, false) == 0)) n_success++; else if ((filetype & BIN_KEYDB) && (CryptAesKeyDb(path, inplace, false) == 0)) n_success++; else { // on failure: show error, continue - char lpathstr[32 * 4 + 1]; + char lpathstr[UTF_BUFFER_BYTESIZE(32)]; TruncateString(lpathstr, path, 32, 8); if (ShowPrompt(true, "%s\nDecryption failed\n \nContinue?", lpathstr)) continue; else break; @@ -1532,7 +1532,7 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, PaneData** pan if (!(filetype & BIN_KEYDB) && (CryptGameFile(path, inplace, true) == 0)) n_success++; else if ((filetype & BIN_KEYDB) && (CryptAesKeyDb(path, inplace, true) == 0)) n_success++; else { // on failure: show error, continue - char lpathstr[32 * 4 + 1]; + char lpathstr[UTF_BUFFER_BYTESIZE(32)]; TruncateString(lpathstr, path, 32, 8); if (ShowPrompt(true, "%s\nEncryption failed\n \nContinue?", lpathstr)) continue; else break; @@ -1570,7 +1570,7 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, PaneData** pan if (((user_select != cxi_dump) && (BuildCiaFromGameFile(path, force_legit) == 0)) || ((user_select == cxi_dump) && (DumpCxiSrlFromGameFile(path) == 0))) n_success++; else { // on failure: show error, continue - char lpathstr[32 * 4 + 1]; + char lpathstr[UTF_BUFFER_BYTESIZE(32)]; TruncateString(lpathstr, path, 32, 8); if (ShowPrompt(true, "%s\nBuild %s failed\n \nContinue?", lpathstr, type)) continue; else break; @@ -1630,7 +1630,7 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, PaneData** pan (install_tik && (InstallTicketFile(path, to_emunand) == 0))) n_success++; else { // on failure: show error, continue - char lpathstr[32 * 4 + 1]; + char lpathstr[UTF_BUFFER_BYTESIZE(32)]; TruncateString(lpathstr, path, 32, 8); if (ShowPrompt(true, "%s\nInstall failed\n \nContinue?", lpathstr)) continue; else break; @@ -1710,7 +1710,7 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, PaneData** pan if ((filetype & IMG_NAND) && (ValidateNandDump(path) == 0)) n_success++; else if (VerifyGameFile(path) == 0) n_success++; else { // on failure: show error, continue - char lpathstr[32 * 4 + 1]; + char lpathstr[UTF_BUFFER_BYTESIZE(32)]; TruncateString(lpathstr, path, 32, 8); if (ShowPrompt(true, "%s\nVerification failed\n \nContinue?", lpathstr)) { if (!(filetype & (GAME_CIA|GAME_TMD|GAME_NCSD|GAME_NCCH))) @@ -1845,7 +1845,7 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, PaneData** pan n_success++; savings += prevsize - FileGetSize(path); } else { // on failure: show error, continue (should not happen) - char lpathstr[32 * 4 + 1]; + char lpathstr[UTF_BUFFER_BYTESIZE(32)]; TruncateString(lpathstr, path, 32, 8); if (ShowPrompt(true, "%s\nTrimming failed\n \nContinue?", lpathstr)) { ShowProgress(0, n_marked, path); // restart progress bar @@ -2488,7 +2488,7 @@ u32 GodMode(int entrypoint) { if (fixcmac > 0) optionstr[fixcmac-1] = "Fix CMACs for drive"; if (dirnfo > 0) optionstr[dirnfo-1] = (*current_path) ? "Show directory info" : "Show drive info"; if (stdcpy > 0) optionstr[stdcpy-1] = "Copy to " OUTPUT_PATH; - char namestr[32 * 4 + 1]; + char namestr[UTF_BUFFER_BYTESIZE(32)]; TruncateString(namestr, (*current_path) ? curr_entry->path : curr_entry->name, 32, 8); int user_select = ShowSelectPrompt(n_opt, optionstr, "%s", namestr); if (user_select == tman) { @@ -2527,7 +2527,7 @@ u32 GodMode(int entrypoint) { u32 user_select = 1; if (curr_drvtype & DRV_SEARCH) { // special menu for search drive static const char* optionstr[2] = { "Open this folder", "Open containing folder" }; - char pathstr[32 * 4 + 1]; + char pathstr[UTF_BUFFER_BYTESIZE(32)]; TruncateString(pathstr, curr_entry->path, 32, 8); user_select = ShowSelectPrompt(2, optionstr, "%s", pathstr); } @@ -2658,7 +2658,7 @@ u32 GodMode(int entrypoint) { if (n_errors) ShowPrompt(false, "Failed deleting %u/%u path(s)", n_errors, n_marked); } } else if (curr_entry->type != T_DOTDOT) { - char namestr[36 * 4 + 1]; + char namestr[UTF_BUFFER_BYTESIZE(28)]; TruncateString(namestr, curr_entry->name, 28, 12); if (ShowPrompt(true, "Delete \"%s\"?", namestr)) { ShowString("Deleting files, please wait..."); @@ -2696,7 +2696,7 @@ u32 GodMode(int entrypoint) { u32 flags = 0; u32 user_select; if (clipboard->n_entries == 1) { - char namestr[20 * 4 + 1]; + char namestr[UTF_BUFFER_BYTESIZE(20)]; TruncateString(namestr, clipboard->entry[0].name, 20, 12); snprintf(promptstr, 64, "Paste \"%s\" here?", namestr); } else snprintf(promptstr, 64, "Paste %lu paths here?", clipboard->n_entries); @@ -2704,7 +2704,7 @@ u32 GodMode(int entrypoint) { ShowSelectPrompt(2, optionstr, "%s", promptstr) : (ShowPrompt(true, "%s", promptstr) ? 1 : 0); if (user_select) { for (u32 c = 0; c < clipboard->n_entries; c++) { - char namestr[36 * 4 + 1]; + char namestr[UTF_BUFFER_BYTESIZE(36)]; TruncateString(namestr, clipboard->entry[c].name, 36, 12); flags &= ~ASK_ALL; if (c < clipboard->n_entries - 1) flags |= ASK_ALL; @@ -2730,7 +2730,7 @@ u32 GodMode(int entrypoint) { ShowPrompt(false, "Not allowed in alias path"); } else if ((pad_state & BUTTON_X) && (curr_entry->type != T_DOTDOT)) { // rename a file char newname[256]; - char namestr[20 * 4 + 1]; + char namestr[UTF_BUFFER_BYTESIZE(20)]; TruncateString(namestr, curr_entry->name, 20, 12); snprintf(newname, 255, "%s", curr_entry->name); if (ShowKeyboardOrPrompt(newname, 256, "Rename %s?\nEnter new name below.", namestr)) { @@ -2754,7 +2754,7 @@ u32 GodMode(int entrypoint) { ((type != 2) || ((fsize = ShowNumberPrompt(0, "Create a new %s here?\nEnter file size below.", typestr)) != (u64) -1))) { if (((type == 1) && !DirCreate(current_path, ename)) || ((type == 2) && !FileCreateDummy(current_path, ename, fsize))) { - char namestr[36 * 4 + 1]; + char namestr[UTF_BUFFER_BYTESIZE(36)]; TruncateString(namestr, ename, 36, 12); ShowPrompt(false, "Failed creating %s:\n%s", typestr, namestr); } else { diff --git a/arm9/source/utils/gameutil.c b/arm9/source/utils/gameutil.c index a6d0cbc..333995d 100644 --- a/arm9/source/utils/gameutil.c +++ b/arm9/source/utils/gameutil.c @@ -527,7 +527,7 @@ u32 VerifyNcchFile(const char* path, u32 offset, u32 size) { ExeFsHeader exefs; FIL file; - char pathstr[32 * 4 + 1]; + char pathstr[UTF_BUFFER_BYTESIZE(32)]; TruncateString(pathstr, path, 32, 8); // open file, get NCCH, ExeFS header @@ -727,7 +727,7 @@ u32 VerifyNcsdFile(const char* path) { NcsdHeader ncsd; // path string - char pathstr[32 * 4 + 1]; + char pathstr[UTF_BUFFER_BYTESIZE(32)]; TruncateString(pathstr, path, 32, 8); // load NCSD header @@ -760,7 +760,7 @@ u32 VerifyCiaFile(const char* path) { if (!cia) return 1; // path string - char pathstr[32 * 4 + 1]; + char pathstr[UTF_BUFFER_BYTESIZE(32)]; TruncateString(pathstr, path, 32, 8); // load CIA stub @@ -805,7 +805,7 @@ u32 VerifyTmdFile(const char* path, bool cdn) { bool ignore_missing_dlc = false; // path string - char pathstr[32 * 4 + 1]; + char pathstr[UTF_BUFFER_BYTESIZE(32)]; TruncateString(pathstr, path, 32, 8); // content path string @@ -905,7 +905,7 @@ u32 VerifyTadFile(const char* path) { } u32 VerifyFirmFile(const char* path) { - char pathstr[32 * 4 + 1]; + char pathstr[UTF_BUFFER_BYTESIZE(32)]; TruncateString(pathstr, path, 32, 8); void* firm_buffer = (void*) malloc(FIRM_MAX_SIZE); @@ -953,7 +953,7 @@ u32 VerifyBossFile(const char* path) { FIL file; UINT btr; - char pathstr[32 * 4 + 1]; + char pathstr[UTF_BUFFER_BYTESIZE(32)]; TruncateString(pathstr, path, 32, 8); // read file header @@ -2897,7 +2897,7 @@ u32 InstallTicketFile(const char* path, bool to_emunand) { return 1; // path string - char pathstr[32 * 4 + 1]; + char pathstr[UTF_BUFFER_BYTESIZE(32)]; TruncateString(pathstr, path, 32, 8); // check ticket db @@ -3389,7 +3389,7 @@ u32 ShowGameCheckerInfo(const char* path) { if (!tmd) return 1; // path string - char pathstr[32 * 4 + 1]; + char pathstr[UTF_BUFFER_BYTESIZE(32)]; TruncateString(pathstr, path, 32, 8); // CIA / TIE specific stuff diff --git a/arm9/source/utils/nandcmac.c b/arm9/source/utils/nandcmac.c index 5a4cc1f..569fdbf 100644 --- a/arm9/source/utils/nandcmac.c +++ b/arm9/source/utils/nandcmac.c @@ -456,7 +456,7 @@ u32 RecursiveFixFileCmacWorker(char* path) { u32 err = 0; if (fvx_opendir(&pdir, path) == FR_OK) { // process folder contents - char pathstr[32 * 4 + 1]; + char pathstr[UTF_BUFFER_BYTESIZE(32)]; TruncateString(pathstr, path, 32, 8); char* fname = path + strnlen(path, 255); *(fname++) = '/'; diff --git a/arm9/source/utils/nandutil.c b/arm9/source/utils/nandutil.c index 381c843..745e4d1 100644 --- a/arm9/source/utils/nandutil.c +++ b/arm9/source/utils/nandutil.c @@ -318,7 +318,7 @@ u32 ValidateNandDump(const char* path) { FIL file; // truncated path string - char pathstr[32 * 4 + 1]; + char pathstr[UTF_BUFFER_BYTESIZE(32)]; TruncateString(pathstr, path, 32, 8); // open file @@ -500,7 +500,7 @@ u32 SafeRestoreNandDump(const char* path) { } u32 SafeInstallFirmBuffered(const char* path, u32 slots, u8* buffer, u32 bufsiz) { - char pathstr[32 * 4 + 1]; // truncated path string + char pathstr[UTF_BUFFER_BYTESIZE(32)]; // truncated path string TruncateString(pathstr, path, 32, 8); // load / check FIRM @@ -610,7 +610,7 @@ u32 SafeInstallKeyDb(const char* path) { static const u8 perfect_sha[] = { KEYDB_PERFECT_HASH }; u8 keydb[KEYDB_PERFECT_SIZE] __attribute__((aligned(4))); - char pathstr[32 * 4 + 1]; // truncated path string + char pathstr[UTF_BUFFER_BYTESIZE(32)]; // truncated path string TruncateString(pathstr, path, 32, 8); // already installed? diff --git a/arm9/source/utils/scripting.c b/arm9/source/utils/scripting.c index e2787a1..97c68fb 100644 --- a/arm9/source/utils/scripting.c +++ b/arm9/source/utils/scripting.c @@ -1832,7 +1832,7 @@ bool FileTextViewer(const char* path, bool as_script) { } bool ExecuteGM9Script(const char* path_script) { - char path_str[32 * 4 + 1]; + char path_str[UTF_BUFFER_BYTESIZE(32)]; TruncateString(path_str, path_script, 32, 12);