From a4a7b8f1e0b91d1e4eed5179af46f17485e2dc17 Mon Sep 17 00:00:00 2001 From: d0k3 Date: Thu, 24 May 2018 00:14:37 +0200 Subject: [PATCH] Fix GCC v8.1 (new dkA) warnings ... this also fixes #371 --- Makefile | 2 +- arm9/source/filesys/filetype.c | 2 ++ arm9/source/filesys/fsdrive.c | 4 +++ arm9/source/filesys/fsgame.c | 2 +- arm9/source/filesys/fsutil.c | 4 ++- arm9/source/gamecart/gamecart.c | 4 +-- arm9/source/godmode.c | 2 ++ arm9/source/utils/ctrtransfer.c | 1 + arm9/source/utils/gameutil.c | 6 +++++ arm9/source/utils/keydbutil.c | 1 + arm9/source/utils/nandutil.c | 2 ++ arm9/source/utils/scripting.c | 21 ++++++++++----- arm9/source/utils/sysinfo.c | 46 ++++++++++++++++++--------------- arm9/source/virtual/virtual.c | 1 + 14 files changed, 66 insertions(+), 32 deletions(-) diff --git a/Makefile b/Makefile index ab5256f..e09e32c 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ export ASFLAGS := -g -x assembler-with-cpp $(INCLUDE) export CFLAGS := -DDBUILTS="\"$(DBUILTS)\"" -DDBUILTL="\"$(DBUILTL)\"" -DVERSION="\"$(VERSION)\"" -DFLAVOR="\"$(FLAVOR)\"" \ -g -O2 -Wall -Wextra -Wpedantic -Wcast-align -Wformat=2 -Wno-main \ -fomit-frame-pointer -ffast-math -std=gnu11 \ - -Wno-unused-function $(INCLUDE) -ffunction-sections -fdata-sections + -Wno-unused-function -Wno-format-truncation $(INCLUDE) -ffunction-sections -fdata-sections export LDFLAGS := -Tlink.ld -nostartfiles -Wl,--gc-sections,-z,max-page-size=512 ELF := arm9/arm9.elf arm11/arm11.elf diff --git a/arm9/source/filesys/filetype.c b/arm9/source/filesys/filetype.c index 825ab17..cf2d135 100644 --- a/arm9/source/filesys/filetype.c +++ b/arm9/source/filesys/filetype.c @@ -125,6 +125,7 @@ u64 IdentifyFileType(const char* path) { char path_cetk[256]; char* ext_cetk = path_cetk + (ext - path); strncpy(path_cetk, path, 256); + path_cetk[255] = '\0'; strncpy(ext_cetk, "cetk", 5); if (FileGetSize(path_cetk) > 0) return GAME_NUSCDN; // NUS/CDN type 2 @@ -152,6 +153,7 @@ u64 IdentifyFileType(const char* path) { char path_cdn[256]; char* name_cdn = path_cdn + (fname - path); strncpy(path_cdn, path, 256); + path_cdn[255] = '\0'; strncpy(name_cdn, "tmd", 4); if (FileGetSize(path_cdn) > 0) return GAME_NUSCDN; // NUS/CDN type 1 diff --git a/arm9/source/filesys/fsdrive.c b/arm9/source/filesys/fsdrive.c index 5bca2f2..a8fcbfd 100644 --- a/arm9/source/filesys/fsdrive.c +++ b/arm9/source/filesys/fsdrive.c @@ -66,7 +66,9 @@ int DriveType(const char* path) { void SetFSSearch(const char* pattern, const char* path, bool mode) { if (pattern && path) { strncpy(search_pattern, pattern, 256); + search_pattern[255] = '\0'; strncpy(search_path, path, 256); + search_path[255] = '\0'; search_title_mode = mode; } else *search_pattern = *search_path = '\0'; } @@ -143,6 +145,7 @@ bool GetDirContentsWorker(DirStruct* contents, char* fpath, int fnsize, const ch } else if (!pattern || (fvx_match_name(fname, pattern) == FR_OK)) { DirEntry* entry = &(contents->entry[contents->n_entries]); strncpy(entry->path, fpath, 256); + entry->path[255] = '\0'; entry->name = entry->path + (fname - fpath); if (fno.fattrib & AM_DIR) { entry->type = T_DIR; @@ -185,6 +188,7 @@ void SearchDirContents(DirStruct* contents, const char* path, const char* patter // search the path char fpath[256]; // 256 is the maximum length of a full path strncpy(fpath, path, 256); + fpath[255] = '\0'; if (!GetDirContentsWorker(contents, fpath, 256, pattern, recursive)) contents->n_entries = 0; } diff --git a/arm9/source/filesys/fsgame.c b/arm9/source/filesys/fsgame.c index 2a226a7..6de3b59 100644 --- a/arm9/source/filesys/fsgame.c +++ b/arm9/source/filesys/fsgame.c @@ -36,7 +36,7 @@ bool GoodRenamer(DirEntry* entry, bool ask) { } char npath[256]; // get new path - strncpy(npath, entry->path, 256 - 1); + strncpy(npath, entry->path, 256); char* nname = strrchr(npath, '/'); if (!nname) return false; nname++; diff --git a/arm9/source/filesys/fsutil.c b/arm9/source/filesys/fsutil.c index 0470969..528e7a8 100644 --- a/arm9/source/filesys/fsutil.c +++ b/arm9/source/filesys/fsutil.c @@ -424,7 +424,8 @@ bool DirInfoWorker(char* fpath, bool virtual, u64* tsize, u32* tdirs, u32* tfile bool DirInfo(const char* path, u64* tsize, u32* tdirs, u32* tfiles) { bool virtual = (DriveType(path) & DRV_VIRTUAL); char fpath[256]; - strncpy(fpath, path, 255); + strncpy(fpath, path, 256); + fpath[255] = '\0'; *tsize = *tdirs = *tfiles = 0; bool res = DirInfoWorker(fpath, virtual, tsize, tdirs, tfiles); return res; @@ -780,6 +781,7 @@ bool FileSelectorWorker(char* result, const char* text, const char* path, const DirStruct* contents = (DirStruct*) buffer; char path_local[256]; strncpy(path_local, path, 256); + path_local[255] = '\0'; bool no_dirs = flags & NO_DIRS; bool no_files = flags & NO_FILES; diff --git a/arm9/source/gamecart/gamecart.c b/arm9/source/gamecart/gamecart.c index ce13912..7cf61a6 100644 --- a/arm9/source/gamecart/gamecart.c +++ b/arm9/source/gamecart/gamecart.c @@ -24,7 +24,7 @@ typedef struct { u64 cart_size; u64 data_size; u32 unused_offset; -} __attribute__((packed)) CartDataCtr; +} __attribute__((packed, aligned(16))) CartDataCtr; typedef struct { TwlHeader ntr_header; @@ -38,7 +38,7 @@ typedef struct { u64 cart_size; u64 data_size; u32 arm9i_rom_offset; -} __attribute__((packed)) CartDataNtrTwl; +} __attribute__((packed, aligned(16))) CartDataNtrTwl; u32 GetCartName(char* name, CartData* cdata) { if (cdata->cart_type & CART_CTR) { diff --git a/arm9/source/godmode.c b/arm9/source/godmode.c index a77d2e3..1d33b58 100644 --- a/arm9/source/godmode.c +++ b/arm9/source/godmode.c @@ -891,6 +891,7 @@ u32 BootFirmHandler(const char* bootpath, bool verbose, bool delete) { if ((*bootpath == '0') || (*bootpath == '1')) snprintf(fixpath, 256, "%s%s", (*bootpath == '0') ? "sdmc" : "nand", bootpath + 1); else strncpy(fixpath, bootpath, 256); + fixpath[255] = '\0'; // boot the FIRM (if we got a proper fixpath) if (*fixpath) { @@ -2161,6 +2162,7 @@ u32 GodMode(int entrypoint) { } if (user_select) { strncpy(current_path, curr_entry->path, 256); + current_path[255] = '\0'; if (user_select == 2) { char* last_slash = strrchr(current_path, '/'); if (last_slash) *last_slash = '\0'; diff --git a/arm9/source/utils/ctrtransfer.c b/arm9/source/utils/ctrtransfer.c index dd63d5a..3618229 100644 --- a/arm9/source/utils/ctrtransfer.c +++ b/arm9/source/utils/ctrtransfer.c @@ -46,6 +46,7 @@ u32 TransferCtrNandImage(const char* path_img, const char* drv) { char path_store[256] = { 0 }; char* path_bak = NULL; strncpy(path_store, GetMountPath(), 256); + path_store[255] = '\0'; if (*path_store) path_bak = path_store; if (!InitImgFS(path_img)) { InitImgFS(path_bak); diff --git a/arm9/source/utils/gameutil.c b/arm9/source/utils/gameutil.c index 10cd6a3..51b999d 100644 --- a/arm9/source/utils/gameutil.c +++ b/arm9/source/utils/gameutil.c @@ -200,6 +200,7 @@ u32 LoadCdnTicketFile(Ticket* ticket, const char* path_cnt) { // path points to CDN content file char path_cetk[256]; strncpy(path_cetk, path_cnt, 256); + path_cetk[255] = '\0'; char* name_cetk = strrchr(path_cetk, '/'); if (!name_cetk) return 1; // will not happen char* ext_cetk = strrchr(++name_cetk, '.'); @@ -221,6 +222,7 @@ u32 GetTmdContentPath(char* path_content, const char* path_tmd) { // content path string char* name_content; strncpy(path_content, path_tmd, 256); + path_content[255] = '\0'; name_content = strrchr(path_content, '/'); if (!name_content) return 1; // will not happen name_content++; @@ -465,6 +467,7 @@ u32 VerifyTmdFile(const char* path, bool cdn) { char path_content[256]; char* name_content; strncpy(path_content, path, 256); + path_content[255] = '\0'; name_content = strrchr(path_content, '/'); if (!name_content) return 1; // will not happen name_content++; @@ -959,6 +962,7 @@ u32 CryptCdnFileBuffered(const char* orig, const char* dest, u16 crypto, void* b if (!strrchr(fname, '.')) { char* name_tmd; strncpy(path_tmd, orig, 256); + path_tmd[255] = '\0'; name_tmd = strrchr(path_tmd, '/'); if (!name_tmd) return 1; // will not happen name_tmd++; @@ -1218,6 +1222,7 @@ u32 BuildCiaFromTmdFileBuffered(const char* path_tmd, const char* path_cia, bool char path_content[256]; char* name_content; strncpy(path_content, path_tmd, 256); + path_content[255] = '\0'; name_content = strrchr(path_content, '/'); if (!name_content) return 1; // will not happen name_content++; @@ -1502,6 +1507,7 @@ u32 ExtractCodeFromCxiFile(const char* path, const char* path_out, char* extstr) char dest[256]; if (!path_out && (fvx_rmkdir(OUTPUT_PATH) != FR_OK)) return 1; strncpy(dest, path_out ? path_out : OUTPUT_PATH, 256); + dest[255] = '\0'; if (!CheckWritePermissions(dest)) return 1; // NCSD handling diff --git a/arm9/source/utils/keydbutil.c b/arm9/source/utils/keydbutil.c index 1dc6ca0..d271bab 100644 --- a/arm9/source/utils/keydbutil.c +++ b/arm9/source/utils/keydbutil.c @@ -136,6 +136,7 @@ u32 BuildKeyDb(const char* path, bool dump) { key.type = 'I'; strncpy(key.id, typestr + 2, 10); } else strncpy(key.id, typestr, 10); + key.id[9] = '\0'; key.slot = keyslot; key.keyUnitType = (strncasecmp(ext, "ret.bin", 10) == 0) ? KEYS_RETAIL : (strncasecmp(ext, "dev.bin", 10) == 0) ? KEYS_DEVKIT : 0; diff --git a/arm9/source/utils/nandutil.c b/arm9/source/utils/nandutil.c index 8f80e2b..fd7564c 100644 --- a/arm9/source/utils/nandutil.c +++ b/arm9/source/utils/nandutil.c @@ -55,6 +55,7 @@ u32 BuildEssentialBackup(const char* path, EssentialBackup* essential) { char path_store[256] = { 0 }; char* path_bak = NULL; strncpy(path_store, GetMountPath(), 256); + path_store[255] = '\0'; if (*path_store) path_bak = path_store; if (!InitImgFS(path)) { InitImgFS(path_bak); @@ -535,6 +536,7 @@ u32 SafeInstallFirmBuffered(const char* path, u32 slots, u8* buffer, u32 bufsiz) if (!IS_O3DS && (ValidateSecretSector(sector0x96) != 0)) { char path_sector[256]; strncpy(path_sector, path, 256); + path_sector[255] = '\0'; char* slash = strrchr(path_sector, '/'); if (slash) strncpy(slash+1, "secret_sector.bin", 256 - (slash+1-path_sector)); else *path_sector = '\0'; diff --git a/arm9/source/utils/scripting.c b/arm9/source/utils/scripting.c index 928e3ae..9b26dea 100644 --- a/arm9/source/utils/scripting.c +++ b/arm9/source/utils/scripting.c @@ -360,7 +360,9 @@ char* set_var(const char* name, const char* content) { if (!*(var->name) || (strncmp(var->name, name, _VAR_NAME_LEN) == 0)) break; if (n_var >= _VAR_MAX_BUFF) return NULL; strncpy(vars[n_var].name, name, _VAR_NAME_LEN); + vars[n_var].name[_VAR_NAME_LEN - 1] = '\0'; strncpy(vars[n_var].content, content, _VAR_CNT_LEN); + vars[n_var].content[_VAR_CNT_LEN - 1] = '\0'; if (!n_var) *(vars[n_var].content) = '\0'; // NULL var // update preview stuff @@ -375,14 +377,14 @@ void upd_var(const char* name) { (strncmp(name, "REGION", _VAR_NAME_LEN) == 0)) { u8 secinfo_data[1 + 1 + 16] = { 0 }; char* env_serial = (char*) secinfo_data + 2; - char env_region[3 + 1]; + char env_region[3 + 1] = { 0 }; snprintf(env_region, 0x4, "UNK"); if ((FileGetData("1:/rw/sys/SecureInfo_A", secinfo_data, 0x11, 0x100) != 0x11) && (FileGetData("1:/rw/sys/SecureInfo_B", secinfo_data, 0x11, 0x100) != 0x11)) snprintf(env_serial, 0xF, "UNKNOWN"); else if (*secinfo_data < SMDH_NUM_REGIONS) - strncpy(env_region, g_regionNamesShort[*secinfo_data], countof(env_region)); + strncpy(env_region, g_regionNamesShort[*secinfo_data], countof(env_region) - 1); set_var("SERIAL", env_serial); set_var("REGION", env_region); @@ -457,9 +459,10 @@ bool init_vars(const char* path_script) { char curr_dir[_VAR_CNT_LEN]; if (path_script) { strncpy(curr_dir, path_script, _VAR_CNT_LEN); + curr_dir[_VAR_CNT_LEN-1] = '\0'; char* slash = strrchr(curr_dir, '/'); if (slash) *slash = '\0'; - } else strncpy(curr_dir, "(null)", _VAR_CNT_LEN); + } else strncpy(curr_dir, "(null)", _VAR_CNT_LEN - 1); // set env vars set_var("NULL", ""); // this one is special and should not be changed later @@ -991,6 +994,7 @@ bool run_cmd(cmd_id id, u32 flags, char** argv, char* err_str) { char input[_VAR_CNT_LEN] = { 0 }; char* var = get_var(argv[1], NULL); strncpy(input, var, _VAR_CNT_LEN); + input[_VAR_CNT_LEN - 1] = '\0'; ret = ShowStringPrompt(input, _VAR_CNT_LEN, "%s", argv[0]); if (ret) set_var(argv[1], ""); if (err_str) snprintf(err_str, _ERR_STR_LEN, "user abort"); @@ -1000,12 +1004,14 @@ bool run_cmd(cmd_id id, u32 flags, char** argv, char* err_str) { } } else if ((id == CMD_ID_FILESEL) || (id == CMD_ID_DIRSEL)) { - char choice[_VAR_CNT_LEN] = { 0 }; + char choice[_VAR_CNT_LEN]; char* var = get_var(argv[2], NULL); strncpy(choice, var, _VAR_CNT_LEN); + choice[_VAR_CNT_LEN - 1] = '\0'; char path[_VAR_CNT_LEN]; strncpy(path, argv[1], _VAR_CNT_LEN); + path[_VAR_CNT_LEN - 1] = '\0'; if (strncmp(path, "Z:", 2) == 0) { ret = false; if (err_str) snprintf(err_str, _ERR_STR_LEN, "forbidden drive"); @@ -1037,6 +1043,7 @@ bool run_cmd(cmd_id id, u32 flags, char** argv, char* err_str) { else if (id == CMD_ID_STRSPLIT) { char str[_ARG_MAX_LEN]; strncpy(str, argv[1], _ARG_MAX_LEN); + str[_ARG_MAX_LEN - 1] = '\0'; ret = false; if (strlen(argv[2]) == 1) { // argv[2] must be one char @@ -1057,6 +1064,7 @@ bool run_cmd(cmd_id id, u32 flags, char** argv, char* err_str) { else if (id == CMD_ID_STRREP) { char str[_ARG_MAX_LEN]; strncpy(str, argv[1], _ARG_MAX_LEN); + str[_ARG_MAX_LEN - 1] = '\0'; if (strnlen(argv[2], _ARG_MAX_LEN) != 2) { if (err_str) snprintf(err_str, _ERR_STR_LEN, "argv[2] must be 2 chars"); @@ -1360,6 +1368,7 @@ bool run_cmd(cmd_id id, u32 flags, char** argv, char* err_str) { if ((*argv[0] == '0') || (*argv[0] == '1')) snprintf(fixpath, 256, "%s%s", (*argv[0] == '0') ? "sdmc" : "nand", argv[0] + 1); else strncpy(fixpath, argv[0], 256); + fixpath[255] = '\0'; BootFirm((FirmHeader*)(void*)firm, fixpath); while(1); } else if (err_str) snprintf(err_str, _ERR_STR_LEN, "not a bootable firm"); @@ -1450,7 +1459,7 @@ bool run_line(const char* line_start, const char* line_end, u32* flags, char* er if ((cmdid == CMD_ID_IF) || (cmdid == CMD_ID_ELIF) || (cmdid == CMD_ID_NOT)) { // set defaults argc = 1; - strncpy(argv[0], _ARG_FALSE, _ARG_MAX_LEN); + strncpy(argv[0], _ARG_FALSE, _ARG_MAX_LEN - 1); // skip to behind the command char* line_start_next = (char*) line_start; @@ -1459,7 +1468,7 @@ bool run_line(const char* line_start, const char* line_end, u32* flags, char* er // run condition, take over result if (run_line(line_start_next, line_end, flags, err_str, true)) - strncpy(argv[0], _ARG_TRUE, _ARG_MAX_LEN); + strncpy(argv[0], _ARG_TRUE, _ARG_MAX_LEN - 1); } // run the command (if available) diff --git a/arm9/source/utils/sysinfo.c b/arm9/source/utils/sysinfo.c index 346cf12..47094a3 100644 --- a/arm9/source/utils/sysinfo.c +++ b/arm9/source/utils/sysinfo.c @@ -80,8 +80,8 @@ void GetSysInfo_Hardware(SysInfo* info, char nand_drive) { (void) nand_drive; info->int_model = 0xFF; - strncpy(info->model, "", countof(info->model)); - strncpy(info->product_code, "???", countof(info->product_code)); + strncpy(info->model, "", countof("")); + strncpy(info->product_code, "???", countof("???")); // Get MCU system information. uint8_t mcu_sysinfo[0x13]; @@ -90,7 +90,9 @@ void GetSysInfo_Hardware(SysInfo* info, char nand_drive) { info->int_model = mcu_sysinfo[0x09]; if (info->int_model < NUM_MODELS) { strncpy(info->model, s_modelNames[info->int_model].name, countof(info->model)); + info->model[countof(info->model) - 1] = '\0'; strncpy(info->product_code, s_modelNames[info->int_model].product_code, countof(info->product_code)); + info->product_code[countof(info->product_code) - 1] = '\0'; } } } @@ -100,7 +102,7 @@ void GetSysInfo_Hardware(SysInfo* info, char nand_drive) { void GetSysInfo_OTP(SysInfo* info, char nand_drive) { (void) nand_drive; - strncpy(info->soc_date, "", countof(info->soc_date)); + strncpy(info->soc_date, "", countof("")); const Otp* otp = &ARM9_ITCM->otp; @@ -136,10 +138,10 @@ void GetSysInfo_SecureInfo(SysInfo* info, char nand_drive) { path[0] = nand_drive; - strncpy(info->sub_model, "", countof(info->sub_model)); - strncpy(info->serial, "", countof(info->serial)); - strncpy(info->system_region, "", countof(info->system_region)); - strncpy(info->sales_region, "", countof(info->sales_region)); + strncpy(info->sub_model, "", countof("")); + strncpy(info->serial, "", countof("")); + strncpy(info->system_region, "", countof("")); + strncpy(info->sales_region, "", countof("")); // Try SecureInfo_A then SecureInfo_B. bool got_data = false; @@ -162,6 +164,7 @@ void GetSysInfo_SecureInfo(SysInfo* info, char nand_drive) { // Decode region. if (data.region < SMDH_NUM_REGIONS) { strncpy(info->system_region, g_regionNamesLong[data.region], countof(info->system_region)); + info->system_region[countof(info->system_region) - 1] = '\0'; } // Retrieve serial number. Set up calculation of check digit. @@ -231,6 +234,7 @@ void GetSysInfo_SecureInfo(SysInfo* info, char nand_drive) { for (unsigned x = 0; x < countof(s_salesRegions); ++x) { if (s_salesRegions[x].serial_char == second_letter) { strncpy(info->sales_region, s_salesRegions[x].name, countof(info->sales_region)); + info->sales_region[countof(info->sales_region) - 1] = '\0'; break; } } @@ -240,21 +244,21 @@ void GetSysInfo_SecureInfo(SysInfo* info, char nand_drive) { if (first_digit && second_digit) { if (IS_DEVKIT) { if ((first_digit == '9') && (second_digit == '0') && (info->int_model == MODEL_OLD_3DS)) { - strncpy(info->sub_model, "Partner-CTR", countof(info->sub_model)); + strncpy(info->sub_model, "Partner-CTR", countof("Partner-CTR")); } else if ((first_digit == '9') && (second_digit == '1') && (info->int_model == MODEL_OLD_3DS)) { - strncpy(info->sub_model, "IS-CTR-BOX", countof(info->sub_model)); + strncpy(info->sub_model, "IS-CTR-BOX", countof("IS-CTR-BOX")); } else if ((first_digit == '9') && (second_digit == '1') && (info->int_model == MODEL_OLD_3DS_XL)) { - strncpy(info->sub_model, "IS-SPR-BOX", countof(info->sub_model)); + strncpy(info->sub_model, "IS-SPR-BOX", countof("IS-SPR-BOX")); } else if ((first_digit == '9') && (second_digit == '1') && (info->int_model == MODEL_NEW_3DS)) { - strncpy(info->sub_model, "IS-SNAKE-BOX", countof(info->sub_model)); + strncpy(info->sub_model, "IS-SNAKE-BOX", countof("IS-SNAKE-BOX")); } else { strncpy(info->sub_model, "panda", countof(info->sub_model)); } } else { if ((first_digit == '0') && (second_digit == '1') && !IS_O3DS) { - strncpy(info->sub_model, "press", countof(info->sub_model)); + strncpy(info->sub_model, "press", countof("press")); } else { - strncpy(info->sub_model, "retail", countof(info->sub_model)); + strncpy(info->sub_model, "retail", countof("retail")); } } } @@ -269,9 +273,9 @@ void GetSysInfo_Movable(SysInfo* info, char nand_drive) { path[0] = nand_drive; - strncpy(info->friendcodeseed, "", countof(info->friendcodeseed)); - strncpy(info->movablekeyy, "", countof(info->movablekeyy)); - strncpy(info->nand_id0, "", countof(info->nand_id0)); + strncpy(info->friendcodeseed, "", countof("")); + strncpy(info->movablekeyy, "", countof("")); + strncpy(info->nand_id0, "", countof("")); if (fvx_qread(path, &data, 0, 0x120 /* sizeof(data) */, NULL) != FR_OK) // whatever, we don't need the last 0x20 byte here return; @@ -296,9 +300,9 @@ void GetSysInfo_SDMMC(SysInfo* info, char nand_drive) { u8 nand_cid[16] = { 0 }; u8 sd_cid[16] = { 0 }; - strncpy(info->nand_cid, "", countof(info->nand_cid)); - strncpy(info->sd_cid, "", countof(info->sd_cid)); - strncpy(info->nand_id1, "", countof(info->nand_id1)); + strncpy(info->nand_cid, "", countof("")); + strncpy(info->sd_cid, "", countof("")); + strncpy(info->nand_id1, "", countof("")); sdmmc_get_cid(1, (u32*) (void*) nand_cid); snprintf(info->nand_cid, 32 + 1, "%016llX%016llX", getbe64(nand_cid), getbe64(nand_cid+8)); @@ -553,8 +557,8 @@ void GetSysInfo_TWLN(SysInfo* info, char nand_drive) { inspect_path[0] = twln_drive; product_path[0] = twln_drive; - strncpy(info->assembly_date, "", countof(info->assembly_date)); - strncpy(info->original_firmware, "", countof(info->original_firmware)); + strncpy(info->assembly_date, "", countof("")); + strncpy(info->original_firmware, "", countof("")); FIL file; if (fvx_open(&file, inspect_path, FA_READ | FA_OPEN_EXISTING) == FR_OK) { diff --git a/arm9/source/virtual/virtual.c b/arm9/source/virtual/virtual.c index d0fb7f8..42b55dc 100644 --- a/arm9/source/virtual/virtual.c +++ b/arm9/source/virtual/virtual.c @@ -100,6 +100,7 @@ bool OpenVirtualDir(VirtualDir* vdir, VirtualFile* ventry) { bool GetVirtualFile(VirtualFile* vfile, const char* path) { char lpath[256]; strncpy(lpath, path, 256); + lpath[255] = '\0'; // get virtual source / root dir object u32 virtual_src = 0;