mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-25 12:46:53 +01:00
strncpy guarantees not tath the result will be null-terminated.
replaced all strncpy with strlcpy if its necessary
This commit is contained in:
parent
75beee7328
commit
572bae91d6
@ -68,8 +68,8 @@ bool HomebrewFiles::LoadPath(const char * folderpath) {
|
||||
|
||||
memset(&(FileInfo[filecount]), 0, sizeof(FileInfo));
|
||||
|
||||
strncpy(FileInfo[filecount].FilePath, folderpath, sizeof(FileInfo[filecount].FilePath));
|
||||
strncpy(FileInfo[filecount].FileName, filename, sizeof(FileInfo[filecount].FileName));
|
||||
strlcpy(FileInfo[filecount].FilePath, folderpath, sizeof(FileInfo[filecount].FilePath));
|
||||
strlcpy(FileInfo[filecount].FileName, filename, sizeof(FileInfo[filecount].FileName));
|
||||
FileInfo[filecount].FileSize = st.st_size;
|
||||
filecount++;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
}
|
||||
//! Set Name
|
||||
void SetName(char * path) {
|
||||
strncpy(name, path, sizeof(name));
|
||||
strlcpy(name, path, sizeof(name));
|
||||
}
|
||||
protected:
|
||||
char name[50];
|
||||
|
@ -25,7 +25,7 @@ int updateLanguageFiles() {
|
||||
//now from the files we got, get only the .lang files
|
||||
for (int cnt = 0; cnt < countfiles; cnt++) {
|
||||
char filename[64];
|
||||
strncpy(filename, GetFileName(cnt),63);
|
||||
strlcpy(filename, GetFileName(cnt),sizeof(filename));
|
||||
if (strcasestr(filename,".lang")) {
|
||||
strcpy(languageFiles[cnt],filename);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ GuiKeyboard::GuiKeyboard(char * t, u32 max, int min, int lang)
|
||||
focus = 0; // allow focus
|
||||
alignmentHor = ALIGN_CENTRE;
|
||||
alignmentVert = ALIGN_MIDDLE;
|
||||
strncpy(kbtextstr, t, max);
|
||||
strlcpy(kbtextstr, t, max);
|
||||
kbtextstr[max] = 0;
|
||||
kbtextmaxlen = max;
|
||||
|
||||
|
@ -1397,9 +1397,9 @@ int MenuDiscList() {
|
||||
if (strlen(get_title(header)) < (MAX_CHARACTERS + 3)) {
|
||||
sprintf(text, "%s", get_title(header));
|
||||
} else {
|
||||
strncpy(text, get_title(header), MAX_CHARACTERS);
|
||||
strlcpy(text, get_title(header), MAX_CHARACTERS+1);
|
||||
text[MAX_CHARACTERS] = '\0';
|
||||
strncat(text, "...", 3);
|
||||
strcat(text, "...");
|
||||
}
|
||||
|
||||
//check if alt Dol and gct file is present
|
||||
|
@ -154,9 +154,8 @@ struct block downloadfile(const char *url) {
|
||||
}
|
||||
|
||||
char domain[domainlength + 1];
|
||||
strncpy(domain, url + strlen("http://"), domainlength);
|
||||
domain[domainlength] = '\0';
|
||||
|
||||
strlcpy(domain, url + strlen("http://"), domainlength+1);
|
||||
|
||||
//Parsing of the URL is done, start making an actual connection
|
||||
u32 ipaddress = getipbynamecached(domain);
|
||||
|
||||
|
@ -177,8 +177,7 @@ s32 download_request(const char * url) {
|
||||
}
|
||||
|
||||
char domain[domainlength + 1];
|
||||
strncpy(domain, url + strlen("http://"), domainlength);
|
||||
domain[domainlength] = '\0';
|
||||
strlcpy(domain, url + strlen("http://"), domainlength+1);
|
||||
|
||||
connection = GetConnection(domain);
|
||||
if (connection < 0) {
|
||||
|
@ -96,8 +96,8 @@ static void GameInstallProgress() {
|
||||
***************************************************************************/
|
||||
void SetupGameInstallProgress(char * title, char * game) {
|
||||
|
||||
strncpy(progressTitle, title, sizeof(progressTitle));
|
||||
strncpy(progressMsg1, game, sizeof(progressMsg1));
|
||||
strlcpy(progressTitle, title, sizeof(progressTitle));
|
||||
strlcpy(progressMsg1, game, sizeof(progressMsg1));
|
||||
gameinstalltotal = 1;
|
||||
showProgress = 1;
|
||||
showSize = true;
|
||||
@ -323,9 +323,9 @@ void ShowProgress(const char *title, const char *msg1, char *dynmsg2, f32 done,
|
||||
showTime = swTime;
|
||||
|
||||
if (title)
|
||||
strncpy(progressTitle, title, sizeof(progressTitle));
|
||||
strlcpy(progressTitle, title, sizeof(progressTitle));
|
||||
if (msg1)
|
||||
strncpy(progressMsg1, msg1, sizeof(progressMsg1));
|
||||
strlcpy(progressMsg1, msg1, sizeof(progressMsg1));
|
||||
if (dynmsg2)
|
||||
dyn_message = dynmsg2;
|
||||
|
||||
|
@ -993,12 +993,12 @@ int MenuSettings() {
|
||||
w.Remove(&optionBrowser2);
|
||||
w.Remove(&backBtn);
|
||||
char entered[20] = "";
|
||||
strncpy(entered, Settings.unlockCode, sizeof(entered));
|
||||
strlcpy(entered, Settings.unlockCode, sizeof(entered));
|
||||
int result = OnScreenKeyboard(entered, 20,0);
|
||||
w.Append(&optionBrowser2);
|
||||
w.Append(&backBtn);
|
||||
if ( result == 1 ) {
|
||||
strncpy(Settings.unlockCode, entered, sizeof(Settings.unlockCode));
|
||||
strlcpy(Settings.unlockCode, entered, sizeof(Settings.unlockCode));
|
||||
WindowPrompt(tr("Password Changed"),tr("Password has been changed"),tr("OK"));
|
||||
}
|
||||
} else {
|
||||
@ -1250,7 +1250,7 @@ int MenuSettings() {
|
||||
w.Remove(&optionBrowser2);
|
||||
w.Remove(&backBtn);
|
||||
char entered[43] = "";
|
||||
strncpy(entered, Settings.covers_path, sizeof(entered));
|
||||
strlcpy(entered, Settings.covers_path, sizeof(entered));
|
||||
titleTxt.SetText(tr("3D Cover Path"));
|
||||
int result = BrowseDevice(entered);
|
||||
//int result = OnScreenKeyboard(entered,43,0);
|
||||
@ -1261,7 +1261,7 @@ int MenuSettings() {
|
||||
int len = (strlen(entered)-1);
|
||||
if (entered[len] !='/')
|
||||
strncat (entered, "/", 1);
|
||||
strncpy(Settings.covers_path, entered, sizeof(Settings.covers_path));
|
||||
strlcpy(Settings.covers_path, entered, sizeof(Settings.covers_path));
|
||||
WindowPrompt(tr("Coverpath Changed"),0,tr("OK"));
|
||||
// if(!isSdInserted()) {
|
||||
if (!isInserted(bootDevice)) {
|
||||
@ -1277,7 +1277,7 @@ int MenuSettings() {
|
||||
w.Remove(&optionBrowser2);
|
||||
w.Remove(&backBtn);
|
||||
char entered[43] = "";
|
||||
strncpy(entered, Settings.covers2d_path, sizeof(entered));
|
||||
strlcpy(entered, Settings.covers2d_path, sizeof(entered));
|
||||
titleTxt.SetText(tr("2D Cover Path"));
|
||||
int result = BrowseDevice(entered);
|
||||
//int result = OnScreenKeyboard(entered,43,0);
|
||||
@ -1288,7 +1288,7 @@ int MenuSettings() {
|
||||
int len = (strlen(entered)-1);
|
||||
if (entered[len] !='/')
|
||||
strncat (entered, "/", 1);
|
||||
strncpy(Settings.covers2d_path, entered, sizeof(Settings.covers2d_path));
|
||||
strlcpy(Settings.covers2d_path, entered, sizeof(Settings.covers2d_path));
|
||||
WindowPrompt(tr("Coverpath Changed"),0,tr("OK"));
|
||||
// if(!isSdInserted()) {
|
||||
if (!isInserted(bootDevice)) {
|
||||
@ -1304,7 +1304,7 @@ int MenuSettings() {
|
||||
w.Remove(&optionBrowser2);
|
||||
w.Remove(&backBtn);
|
||||
char entered[43] = "";
|
||||
strncpy(entered, Settings.disc_path, sizeof(entered));
|
||||
strlcpy(entered, Settings.disc_path, sizeof(entered));
|
||||
titleTxt.SetText(tr("Discimage Path"));
|
||||
int result = BrowseDevice(entered);
|
||||
//int result = OnScreenKeyboard(entered, 43,0);
|
||||
@ -1315,7 +1315,7 @@ int MenuSettings() {
|
||||
int len = (strlen(entered)-1);
|
||||
if (entered[len] !='/')
|
||||
strncat (entered, "/", 1);
|
||||
strncpy(Settings.disc_path, entered, sizeof(Settings.disc_path));
|
||||
strlcpy(Settings.disc_path, entered, sizeof(Settings.disc_path));
|
||||
WindowPrompt(tr("Discpath Changed"),0,tr("OK"));
|
||||
// if(!isSdInserted()) {
|
||||
if (!isInserted(bootDevice)) {
|
||||
@ -1332,7 +1332,7 @@ int MenuSettings() {
|
||||
w.Remove(&backBtn);
|
||||
char entered[43] = "";
|
||||
titleTxt.SetText(tr("ThemePath"));
|
||||
strncpy(entered, CFG.theme_path, sizeof(entered));
|
||||
strlcpy(entered, CFG.theme_path, sizeof(entered));
|
||||
int result = BrowseDevice(entered);
|
||||
//int result = OnScreenKeyboard(entered, 43,0);
|
||||
HaltGui();
|
||||
@ -1341,7 +1341,7 @@ int MenuSettings() {
|
||||
int len = (strlen(entered)-1);
|
||||
if (entered[len] !='/')
|
||||
strncat (entered, "/", 1);
|
||||
strncpy(CFG.theme_path, entered, sizeof(CFG.theme_path));
|
||||
strlcpy(CFG.theme_path, entered, sizeof(CFG.theme_path));
|
||||
WindowPrompt(tr("Themepath Changed"),0,tr("OK"));
|
||||
// if(!isSdInserted()) {
|
||||
if (!isInserted(bootDevice)) {
|
||||
@ -1390,7 +1390,7 @@ int MenuSettings() {
|
||||
w.Remove(&backBtn);
|
||||
char entered[43] = "";
|
||||
titleTxt.SetText(tr("XMLPath"));
|
||||
strncpy(entered, Settings.titlestxt_path, sizeof(entered));
|
||||
strlcpy(entered, Settings.titlestxt_path, sizeof(entered));
|
||||
int result = BrowseDevice(entered);
|
||||
//int result = OnScreenKeyboard(entered,43,0);
|
||||
w.Append(&optionBrowser2);
|
||||
@ -1400,7 +1400,7 @@ int MenuSettings() {
|
||||
int len = (strlen(entered)-1);
|
||||
if (entered[len] !='/')
|
||||
strncat (entered, "/", 1);
|
||||
strncpy(Settings.titlestxt_path, entered, sizeof(Settings.titlestxt_path));
|
||||
strlcpy(Settings.titlestxt_path, entered, sizeof(Settings.titlestxt_path));
|
||||
WindowPrompt(tr("XMLPath changed."),0,tr("OK"));
|
||||
// if(isSdInserted()) {
|
||||
if (isInserted(bootDevice)) {
|
||||
@ -1421,7 +1421,7 @@ int MenuSettings() {
|
||||
w.Remove(&optionBrowser2);
|
||||
w.Remove(&backBtn);
|
||||
char entered[43] = "";
|
||||
strncpy(entered, Settings.update_path, sizeof(entered));
|
||||
strlcpy(entered, Settings.update_path, sizeof(entered));
|
||||
titleTxt.SetText(tr("Updatepath"));
|
||||
int result = BrowseDevice(entered);
|
||||
//int result = OnScreenKeyboard(entered,43,0);
|
||||
@ -1432,7 +1432,7 @@ int MenuSettings() {
|
||||
int len = (strlen(entered)-1);
|
||||
if (entered[len] !='/')
|
||||
strncat (entered, "/", 1);
|
||||
strncpy(Settings.update_path, entered, sizeof(Settings.update_path));
|
||||
strlcpy(Settings.update_path, entered, sizeof(Settings.update_path));
|
||||
WindowPrompt(tr("Updatepath changed."),0,tr("OK"));
|
||||
}
|
||||
} else
|
||||
@ -1443,7 +1443,7 @@ int MenuSettings() {
|
||||
w.Remove(&optionBrowser2);
|
||||
w.Remove(&backBtn);
|
||||
char entered[43] = "";
|
||||
strncpy(entered, Settings.Cheatcodespath, sizeof(entered));
|
||||
strlcpy(entered, Settings.Cheatcodespath, sizeof(entered));
|
||||
titleTxt.SetText(tr("Cheatcodes Path"));
|
||||
int result = BrowseDevice(entered);
|
||||
//int result = OnScreenKeyboard(entered,43,0);
|
||||
@ -1454,7 +1454,7 @@ int MenuSettings() {
|
||||
int len = (strlen(entered)-1);
|
||||
if (entered[len] !='/')
|
||||
strncat (entered, "/", 1);
|
||||
strncpy(Settings.Cheatcodespath, entered, sizeof(Settings.Cheatcodespath));
|
||||
strlcpy(Settings.Cheatcodespath, entered, sizeof(Settings.Cheatcodespath));
|
||||
WindowPrompt(tr("Cheatcodes Path changed"),0,tr("OK"));
|
||||
}
|
||||
} else
|
||||
@ -1465,7 +1465,7 @@ int MenuSettings() {
|
||||
w.Remove(&optionBrowser2);
|
||||
w.Remove(&backBtn);
|
||||
char entered[43] = "";
|
||||
strncpy(entered, Settings.TxtCheatcodespath, sizeof(entered));
|
||||
strlcpy(entered, Settings.TxtCheatcodespath, sizeof(entered));
|
||||
titleTxt.SetText(tr("TXTCheatcodes Path"));
|
||||
int result = BrowseDevice(entered);
|
||||
//int result = OnScreenKeyboard(entered,43,0);
|
||||
@ -1476,7 +1476,7 @@ int MenuSettings() {
|
||||
int len = (strlen(entered)-1);
|
||||
if (entered[len] !='/')
|
||||
strncat (entered, "/", 1);
|
||||
strncpy(Settings.TxtCheatcodespath, entered, sizeof(Settings.TxtCheatcodespath));
|
||||
strlcpy(Settings.TxtCheatcodespath, entered, sizeof(Settings.TxtCheatcodespath));
|
||||
WindowPrompt(tr("TXTCheatcodes Path changed"),0,tr("OK"));
|
||||
}
|
||||
} else
|
||||
@ -1487,7 +1487,7 @@ int MenuSettings() {
|
||||
w.Remove(&optionBrowser2);
|
||||
w.Remove(&backBtn);
|
||||
char entered[43] = "";
|
||||
strncpy(entered, Settings.dolpath, sizeof(entered));
|
||||
strlcpy(entered, Settings.dolpath, sizeof(entered));
|
||||
titleTxt.SetText(tr("Dol Path"));
|
||||
int result = BrowseDevice(entered);
|
||||
//int result = OnScreenKeyboard(entered,43,0);
|
||||
@ -1498,7 +1498,7 @@ int MenuSettings() {
|
||||
int len = (strlen(entered)-1);
|
||||
if (entered[len] !='/')
|
||||
strncat (entered, "/", 1);
|
||||
strncpy(Settings.dolpath, entered, sizeof(Settings.dolpath));
|
||||
strlcpy(Settings.dolpath, entered, sizeof(Settings.dolpath));
|
||||
WindowPrompt(tr("Dolpath Changed"),0,tr("OK"));
|
||||
// if(!isSdInserted()) {
|
||||
if (!isInserted(bootDevice)) {
|
||||
@ -1514,7 +1514,7 @@ int MenuSettings() {
|
||||
w.Remove(&optionBrowser2);
|
||||
w.Remove(&backBtn);
|
||||
char entered[43] = "";
|
||||
strncpy(entered, Settings.homebrewapps_path, sizeof(entered));
|
||||
strlcpy(entered, Settings.homebrewapps_path, sizeof(entered));
|
||||
titleTxt.SetText(tr("Homebrew Apps Path"));
|
||||
int result = BrowseDevice(entered);
|
||||
//int result = OnScreenKeyboard(entered,43,0);
|
||||
@ -1525,7 +1525,7 @@ int MenuSettings() {
|
||||
int len = (strlen(entered)-1);
|
||||
if (entered[len] !='/')
|
||||
strncat (entered, "/", 1);
|
||||
strncpy(Settings.homebrewapps_path, entered, sizeof(Settings.homebrewapps_path));
|
||||
strlcpy(Settings.homebrewapps_path, entered, sizeof(Settings.homebrewapps_path));
|
||||
WindowPrompt(tr("Homebrew Appspath changed"),0,tr("OK"));
|
||||
// if(!isSdInserted()) {
|
||||
if (!isInserted(bootDevice)) {
|
||||
@ -1797,11 +1797,10 @@ int GameSettings(struct discHdr * header) {
|
||||
char gameName[31];
|
||||
|
||||
if (strlen(get_title(header)) < (27 + 3)) {
|
||||
sprintf(gameName, "%s", get_title(header));
|
||||
strcpy(gameName, get_title(header));
|
||||
} else {
|
||||
strncpy(gameName, get_title(header), 27);
|
||||
gameName[27] = '\0';
|
||||
strncat(gameName, "...", 3);
|
||||
strlcpy(gameName, get_title(header), 27+1);
|
||||
strcat(gameName, "...");
|
||||
}
|
||||
|
||||
|
||||
|
@ -218,7 +218,7 @@ bool MenuOGG() {
|
||||
w.Remove(&stopBtn);
|
||||
w.Remove(&defaultBtn);
|
||||
char entered[43] = "";
|
||||
strncpy(entered, Settings.oggload_path, sizeof(entered));
|
||||
strlcpy(entered, Settings.oggload_path, sizeof(entered));
|
||||
int result = OnScreenKeyboard(entered,43,0);
|
||||
w.Append(&optionBrowser4);
|
||||
w.Append(&pathBtn);
|
||||
@ -230,7 +230,7 @@ bool MenuOGG() {
|
||||
int len = (strlen(entered)-1);
|
||||
if (entered[len] !='/')
|
||||
strncat (entered, "/", 1);
|
||||
strncpy(Settings.oggload_path, entered, sizeof(Settings.oggload_path));
|
||||
strlcpy(Settings.oggload_path, entered, sizeof(Settings.oggload_path));
|
||||
WindowPrompt(tr("Backgroundmusic Path changed."),0,tr("OK"));
|
||||
// if(isSdInserted()) {
|
||||
if (isInserted(bootDevice)) {
|
||||
@ -419,7 +419,7 @@ int MenuLanguageSelect() {
|
||||
|
||||
for (cnt = 0; cnt < countfiles; cnt++) {
|
||||
char filename[64];
|
||||
strncpy(filename, GetFileName(cnt),63);
|
||||
strlcpy(filename, GetFileName(cnt), sizeof(filename));
|
||||
char *dot = strchr(filename, '.');
|
||||
if (dot) *dot='\0';
|
||||
options2.SetName(cnt, "%s", filename);
|
||||
@ -537,7 +537,7 @@ int MenuLanguageSelect() {
|
||||
w.Remove(&pathBtn);
|
||||
w.Remove(&defaultBtn);
|
||||
char entered[43] = "";
|
||||
strncpy(entered, Settings.languagefiles_path, sizeof(entered));
|
||||
strlcpy(entered, Settings.languagefiles_path, sizeof(entered));
|
||||
int result = OnScreenKeyboard(entered,43,0);
|
||||
w.Append(&optionBrowser4);
|
||||
w.Append(&pathBtn);
|
||||
@ -547,7 +547,7 @@ int MenuLanguageSelect() {
|
||||
int len = (strlen(entered)-1);
|
||||
if (entered[len] !='/')
|
||||
strncat (entered, "/", 1);
|
||||
strncpy(Settings.languagefiles_path, entered, sizeof(Settings.languagefiles_path));
|
||||
strlcpy(Settings.languagefiles_path, entered, sizeof(Settings.languagefiles_path));
|
||||
WindowPrompt(tr("Languagepath changed."),0,tr("OK"));
|
||||
// if(isSdInserted()) {
|
||||
if (isInserted(bootDevice)) {
|
||||
|
@ -111,11 +111,6 @@ struct TextMap map_alignment[] = {
|
||||
{ "middle", CFG_ALIGN_MIDDLE },
|
||||
{ NULL, -1 }
|
||||
};
|
||||
char* strcopy(char *dest, char *src, int size) {
|
||||
strncpy(dest,src,size);
|
||||
dest[size-1] = 0;
|
||||
return dest;
|
||||
}
|
||||
|
||||
int map_get_id(struct TextMap *map, char *name) {
|
||||
int i;
|
||||
@ -371,7 +366,7 @@ void title_set(char *id, char *title) {
|
||||
char *idt = cfg_get_title((u8*)id);
|
||||
if (idt) {
|
||||
// replace
|
||||
strcopy(idt, title, TITLE_MAX);
|
||||
strlcpy(idt, title, TITLE_MAX);
|
||||
} else {
|
||||
cfg_title = realloc(cfg_title, (num_title+1) * sizeof(struct ID_Title));
|
||||
if (!cfg_title) {
|
||||
@ -382,7 +377,7 @@ void title_set(char *id, char *title) {
|
||||
// add
|
||||
memcpy(cfg_title[num_title].id, id, 4);
|
||||
cfg_title[num_title].id[4] = 0;
|
||||
strcopy(cfg_title[num_title].title, title, TITLE_MAX);
|
||||
strlcpy(cfg_title[num_title].title, title, TITLE_MAX);
|
||||
num_title++;
|
||||
}
|
||||
}
|
||||
@ -392,7 +387,7 @@ void titles_default() {
|
||||
for (i=0; i<num_title; i++) {
|
||||
memcpy(cfg_title[i].id, "", 4);
|
||||
cfg_title[i].id[4] = 0;
|
||||
strcopy(cfg_title[i].title, "", TITLE_MAX);
|
||||
strlcpy(cfg_title[i].title, "", TITLE_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
@ -424,8 +419,7 @@ char* trim_n_copy(char *dest, char *src, int n, int size) {
|
||||
// trim trailing white space
|
||||
while (len > 0 && isspace(src[len-1])) len--;
|
||||
if (len >= size) len = size-1;
|
||||
strncpy(dest, src, len);
|
||||
dest[len] = 0;
|
||||
strlcpy(dest, src, len+1);
|
||||
//printf("trim_copy: '%s' %d\n", dest, len); //sleep(1);
|
||||
return dest;
|
||||
}
|
||||
@ -437,8 +431,7 @@ char* trimcopy(char *dest, char *src, int size) {
|
||||
// trim trailing " \r\n"
|
||||
while (len > 0 && strchr(" \r\n", src[len-1])) len--;
|
||||
if (len >= size) len = size-1;
|
||||
strncpy(dest, src, len);
|
||||
dest[len] = 0;
|
||||
strlcpy(dest, src, len+1);
|
||||
return dest;
|
||||
}
|
||||
|
||||
@ -460,67 +453,67 @@ void path_set(char *name, char *val) {
|
||||
// if these are defined in txt file, use them. otherwise use defaults
|
||||
|
||||
if (!CFG.widescreen &&(strcmp(name, "theme_path") == 0)) {// if in 4:3
|
||||
strcopy(CFG.theme_path, val, sizeof(CFG.theme_path));
|
||||
strlcpy(CFG.theme_path, val, sizeof(CFG.theme_path));
|
||||
return;
|
||||
}
|
||||
|
||||
if (CFG.widescreen && strcmp(name, "wtheme_path") == 0) { // if in 16:9
|
||||
strcopy(CFG.theme_path, val, sizeof(CFG.theme_path));
|
||||
strlcpy(CFG.theme_path, val, sizeof(CFG.theme_path));
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(name, "cover_path") == 0) {
|
||||
strcopy(Settings.covers_path, val, sizeof(Settings.covers_path));
|
||||
strlcpy(Settings.covers_path, val, sizeof(Settings.covers_path));
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(name, "cover2d_path") == 0) {
|
||||
strcopy(Settings.covers2d_path, val, sizeof(Settings.covers2d_path));
|
||||
strlcpy(Settings.covers2d_path, val, sizeof(Settings.covers2d_path));
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(name, "disc_path") == 0) {
|
||||
strcopy(Settings.disc_path, val, sizeof(Settings.disc_path));
|
||||
strlcpy(Settings.disc_path, val, sizeof(Settings.disc_path));
|
||||
return;
|
||||
}
|
||||
if (strcmp(name, "titlestxt_path") == 0) {
|
||||
strcopy(Settings.titlestxt_path, val, sizeof(Settings.titlestxt_path));
|
||||
strlcpy(Settings.titlestxt_path, val, sizeof(Settings.titlestxt_path));
|
||||
return;
|
||||
}
|
||||
if (strcmp(name, "language_path") == 0) {
|
||||
strcopy(Settings.language_path, val, sizeof(Settings.language_path));
|
||||
strlcpy(Settings.language_path, val, sizeof(Settings.language_path));
|
||||
return;
|
||||
}
|
||||
if (strcmp(name, "languagefiles_path") == 0) {
|
||||
strcopy(Settings.languagefiles_path, val, sizeof(Settings.languagefiles_path));
|
||||
strlcpy(Settings.languagefiles_path, val, sizeof(Settings.languagefiles_path));
|
||||
return;
|
||||
}
|
||||
if (strcmp(name, "update_path") == 0) {
|
||||
strcopy(Settings.update_path, val, sizeof(Settings.update_path));
|
||||
strlcpy(Settings.update_path, val, sizeof(Settings.update_path));
|
||||
return;
|
||||
}
|
||||
if (strcmp(name, "homebrewapps_path") == 0) {
|
||||
strcopy(Settings.homebrewapps_path, val, sizeof(Settings.homebrewapps_path));
|
||||
strlcpy(Settings.homebrewapps_path, val, sizeof(Settings.homebrewapps_path));
|
||||
return;
|
||||
}
|
||||
if (strcmp(name, "Cheatcodespath") == 0) {
|
||||
strcopy(Settings.Cheatcodespath, val, sizeof(Settings.Cheatcodespath));
|
||||
strlcpy(Settings.Cheatcodespath, val, sizeof(Settings.Cheatcodespath));
|
||||
return;
|
||||
}
|
||||
if (strcmp(name, "TxtCheatcodespath") == 0) {
|
||||
strcopy(Settings.TxtCheatcodespath, val, sizeof(Settings.TxtCheatcodespath));
|
||||
strlcpy(Settings.TxtCheatcodespath, val, sizeof(Settings.TxtCheatcodespath));
|
||||
return;
|
||||
}
|
||||
if (strcmp(name, "oggload_path") == 0) {
|
||||
strcopy(Settings.oggload_path, val, sizeof(Settings.oggload_path));
|
||||
strlcpy(Settings.oggload_path, val, sizeof(Settings.oggload_path));
|
||||
return;
|
||||
}
|
||||
if (strcmp(name, "dolpath") == 0) {
|
||||
strcopy(Settings.dolpath, val, sizeof(Settings.dolpath));
|
||||
strlcpy(Settings.dolpath, val, sizeof(Settings.dolpath));
|
||||
return;
|
||||
}
|
||||
if (strcmp(name, "ogg_path") == 0) {
|
||||
strcopy(Settings.ogg_path, val, sizeof(Settings.ogg_path));
|
||||
strlcpy(Settings.ogg_path, val, sizeof(Settings.ogg_path));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -882,7 +875,7 @@ void global_cfg_set(char *name, char *val) {
|
||||
}
|
||||
return;
|
||||
} else if (strcmp(name, "password") == 0) {
|
||||
strcopy(Settings.unlockCode, val, sizeof(Settings.unlockCode));
|
||||
strlcpy(Settings.unlockCode, val, sizeof(Settings.unlockCode));
|
||||
return;
|
||||
} else if (strcmp(name, "parentalcontrol") == 0) {
|
||||
int i;
|
||||
@ -992,7 +985,7 @@ bool trimsplit(char *line, char *part1, char *part2, char delim, int size) {
|
||||
void cfg_parseline(char *line, void (*set_func)(char*, char*)) {
|
||||
// split name = value
|
||||
char tmp[300], name[200], val[200];
|
||||
strcopy(tmp, line, sizeof(tmp));
|
||||
strlcpy(tmp, line, sizeof(tmp));
|
||||
char *eq = strchr(tmp, '=');
|
||||
if (!eq) return;
|
||||
*eq = 0;
|
||||
@ -1006,7 +999,7 @@ void cfg_parsetitleline(char *line, void (*set_func)(char*, char*, u8)) {
|
||||
// split name = value
|
||||
char tmp[200], name[200], val[200];
|
||||
int block = 0;
|
||||
strcopy(tmp, line, sizeof(tmp));
|
||||
strlcpy(tmp, line, sizeof(tmp));
|
||||
char *eq = strchr(tmp, '=');
|
||||
if (!eq) return;
|
||||
*eq = 0;
|
||||
|
@ -369,7 +369,7 @@ static int _ISFS_dirnext_r(struct _reent *r, DIR_ITER *dirState, char *filename,
|
||||
return -1;
|
||||
}
|
||||
DIR_ENTRY *entry = &state->entry->children[state->index++];
|
||||
strncpy(filename, entry->name, ISFS_MAXPATHLEN - 1);
|
||||
strlcpy(filename, entry->name, ISFS_MAXPATHLEN);
|
||||
stat_entry(entry, st);
|
||||
return 0;
|
||||
}
|
||||
|
@ -670,8 +670,8 @@ void PrintGameInfo(bool showfullinfo) {
|
||||
snprintf(linebuf, sizeof(linebuf), "%s / %s", linebuf, gameinfo.developer);
|
||||
if (strlen(linebuf) >= 100) {
|
||||
char buffer[200] = "";
|
||||
strncpy(buffer, linebuf, 100);
|
||||
strncat(buffer, "...", 3);
|
||||
strlcpy(buffer, linebuf, 100);
|
||||
strcat(buffer, "...");
|
||||
snprintf(linebuf, sizeof(linebuf), "%s", buffer);
|
||||
}
|
||||
printf("%s\n",linebuf);
|
||||
|
Loading…
Reference in New Issue
Block a user