mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 13:42:47 +00:00
Misc code improvements
This commit is contained in:
parent
58fb9913d5
commit
e41b098843
@ -651,7 +651,7 @@ u32 ShowFileScrollPrompt(u32 n, const DirEntry** options, bool hide_ext, const c
|
||||
|
||||
char content_str[64 + 1];
|
||||
char temp_str[256];
|
||||
strncpy(temp_str, options[i]->name, 255);
|
||||
strncpy(temp_str, options[i]->name, 256);
|
||||
|
||||
char* dot = strrchr(temp_str, '.');
|
||||
if (hide_ext && dot) *dot = '\0';
|
||||
|
@ -606,8 +606,8 @@ bool PathMoveCopy(const char* dest, const char* orig, u32* flags, bool move) {
|
||||
int odrvtype = DriveType(orig);
|
||||
char ldest[256]; // 256 is the maximum length of a full path
|
||||
char lorig[256];
|
||||
strncpy(ldest, dest, 255);
|
||||
strncpy(lorig, orig, 255);
|
||||
strncpy(ldest, dest, 256);
|
||||
strncpy(lorig, orig, 256);
|
||||
char deststr[36 + 1];
|
||||
TruncateString(deststr, ldest, 36, 8);
|
||||
|
||||
@ -883,6 +883,7 @@ bool FileSelector(char* result, const char* text, const char* path, const char*
|
||||
void* buffer = (void*) malloc(sizeof(DirStruct));
|
||||
if (!buffer) return false;
|
||||
|
||||
// for this to work, result needs to be at least 256 bytes in size
|
||||
bool ret = FileSelectorWorker(result, text, path, pattern, flags, buffer, new_style);
|
||||
free(buffer);
|
||||
return ret;
|
||||
|
@ -74,6 +74,6 @@ u64 MountImage(const char* path) {
|
||||
return 0;
|
||||
fvx_lseek(&mount_file, 0);
|
||||
fvx_sync(&mount_file);
|
||||
strncpy(mount_path, path, 255);
|
||||
strncpy(mount_path, path, 256);
|
||||
return (mount_state = type);
|
||||
}
|
||||
|
@ -35,9 +35,9 @@ int alias_num (const TCHAR* path) {
|
||||
void dealias_path (TCHAR* alias, const TCHAR* path) {
|
||||
int num = alias_num(path);
|
||||
u32 p_offs = (path[2] == '/' && ((path[3] == '/') || (path[3] == '\0'))) ? 3 : 2;
|
||||
if (num >= 0) // set alias (alias is assumed to be 256 byte)
|
||||
if (num >= 0) // set alias (alias is assumed to be 256 byte!)
|
||||
snprintf(alias, 256, "%s%s", alias_path[num], path + p_offs);
|
||||
else strncpy(alias, path, 256);
|
||||
else snprintf(alias, 256, "%s", path);
|
||||
}
|
||||
|
||||
FilCryptInfo* fx_find_cryptinfo(FIL* fptr) {
|
||||
|
@ -115,6 +115,7 @@ bool CheckSupportDir(const char* dname)
|
||||
bool FileSelectorSupport(char* result, const char* text, const char* dname, const char* pattern)
|
||||
{
|
||||
char path[256];
|
||||
// result needs to be at least 256 bytes long for this to work!
|
||||
if (!GetSupportDir(path, dname)) return false;
|
||||
return FileSelector(result, text, path, pattern, HIDE_EXT, false);
|
||||
}
|
||||
|
@ -2194,7 +2194,7 @@ u32 GodMode(int entrypoint) {
|
||||
const u32 quick_stp = (MAIN_SCREEN == TOP_SCREEN) ? 20 : 19;
|
||||
u32 exit_mode = GODMODE_EXIT_POWEROFF;
|
||||
|
||||
char current_path[256] = { 0x00 };
|
||||
char current_path[256] = { 0x00 }; // don't change this size!
|
||||
u32 cursor = 0;
|
||||
u32 scroll = 0;
|
||||
|
||||
|
@ -238,12 +238,14 @@ u32 LoadCdnTicketFile(Ticket** ticket, const char* path_cnt) {
|
||||
}
|
||||
|
||||
u32 GetTmdContentPath(char* path_content, const char* path_tmd) {
|
||||
// path_content should be 256 bytes in size!
|
||||
|
||||
// get path to TMD first content
|
||||
static const u8 dlc_tid_high[] = { DLC_TID_HIGH };
|
||||
|
||||
// content path string
|
||||
char* name_content;
|
||||
strncpy(path_content, path_tmd, 256);
|
||||
snprintf(path_content, 255, "%s", path_tmd);
|
||||
path_content[255] = '\0';
|
||||
name_content = strrchr(path_content, '/');
|
||||
if (!name_content) return 1; // will not happen
|
||||
@ -2450,6 +2452,8 @@ u32 ExtractCodeFromCxiFile(const char* path, const char* path_out, char* extstr)
|
||||
dest[255] = '\0';
|
||||
if (!CheckWritePermissions(dest)) return 1;
|
||||
|
||||
// extstr should be at least 16 bytes in size
|
||||
|
||||
// NCSD handling
|
||||
u32 ncch_offset = 0;
|
||||
if (filetype & GAME_NCSD) {
|
||||
|
@ -774,7 +774,7 @@ bool for_handler(char* path, const char* dir, const char* pattern, bool recursiv
|
||||
snprintf(path, 256, "%s/%.254s", ldir, fno.fname);
|
||||
if (rec && (fno.fattrib & AM_DIR) && (dp - fdir < _MAX_FOR_DEPTH - 1)) {
|
||||
if (fvx_opendir(++dp, path) != FR_OK) dp--;
|
||||
else strncpy(ldir, path, 255);
|
||||
else strncpy(ldir, path, 256);
|
||||
}
|
||||
} else return false;
|
||||
|
||||
|
@ -244,6 +244,7 @@ void GetSysInfo_SecureInfo(SysInfo* info, char nand_drive) {
|
||||
// Determine the sub-model from the first two digits of the digit part.
|
||||
if (first_digit && second_digit) {
|
||||
if (IS_DEVKIT) {
|
||||
// missing: identification for IS-CLOSER-BOX (issue #276)
|
||||
if ((first_digit == '9') && (second_digit == '0') && (info->int_model == MODEL_OLD_3DS)) {
|
||||
strncpy(info->sub_model, "Partner-CTR", countof("Partner-CTR"));
|
||||
} else if ((first_digit == '9') && (second_digit == '1') && (info->int_model == MODEL_OLD_3DS)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user