diff --git a/_Projects_/updater/pkgfiles/USRDIR/webftp_server_full.sprx b/_Projects_/updater/pkgfiles/USRDIR/webftp_server_full.sprx index 3ff9788b..52a2148c 100644 Binary files a/_Projects_/updater/pkgfiles/USRDIR/webftp_server_full.sprx and b/_Projects_/updater/pkgfiles/USRDIR/webftp_server_full.sprx differ diff --git a/_Projects_/updater/pkgfiles/USRDIR/webftp_server_lite.sprx b/_Projects_/updater/pkgfiles/USRDIR/webftp_server_lite.sprx index b946d7b7..dbe63cf6 100644 Binary files a/_Projects_/updater/pkgfiles/USRDIR/webftp_server_lite.sprx and b/_Projects_/updater/pkgfiles/USRDIR/webftp_server_lite.sprx differ diff --git a/_Projects_/updater/pkgfiles/USRDIR/webftp_server_noncobra.sprx b/_Projects_/updater/pkgfiles/USRDIR/webftp_server_noncobra.sprx index bfdca7a5..4e46351a 100644 Binary files a/_Projects_/updater/pkgfiles/USRDIR/webftp_server_noncobra.sprx and b/_Projects_/updater/pkgfiles/USRDIR/webftp_server_noncobra.sprx differ diff --git a/_Projects_/updater/pkgfiles/USRDIR/webftp_server_rebug_cobra_ps3mapi.sprx b/_Projects_/updater/pkgfiles/USRDIR/webftp_server_rebug_cobra_ps3mapi.sprx index 1285b663..1d4e97ac 100644 Binary files a/_Projects_/updater/pkgfiles/USRDIR/webftp_server_rebug_cobra_ps3mapi.sprx and b/_Projects_/updater/pkgfiles/USRDIR/webftp_server_rebug_cobra_ps3mapi.sprx differ diff --git a/_Projects_/updater/update/dev_hdd0/plugins/webftp_server.sprx b/_Projects_/updater/update/dev_hdd0/plugins/webftp_server.sprx index 3ff9788b..52a2148c 100644 Binary files a/_Projects_/updater/update/dev_hdd0/plugins/webftp_server.sprx and b/_Projects_/updater/update/dev_hdd0/plugins/webftp_server.sprx differ diff --git a/_Projects_/updater/update/dev_hdd0/plugins/webftp_server_lite.sprx b/_Projects_/updater/update/dev_hdd0/plugins/webftp_server_lite.sprx index b946d7b7..dbe63cf6 100644 Binary files a/_Projects_/updater/update/dev_hdd0/plugins/webftp_server_lite.sprx and b/_Projects_/updater/update/dev_hdd0/plugins/webftp_server_lite.sprx differ diff --git a/_Projects_/updater/update/dev_hdd0/plugins/webftp_server_noncobra.sprx b/_Projects_/updater/update/dev_hdd0/plugins/webftp_server_noncobra.sprx index bfdca7a5..4e46351a 100644 Binary files a/_Projects_/updater/update/dev_hdd0/plugins/webftp_server_noncobra.sprx and b/_Projects_/updater/update/dev_hdd0/plugins/webftp_server_noncobra.sprx differ diff --git a/flags.h b/flags.h index 52328560..1e625155 100644 --- a/flags.h +++ b/flags.h @@ -6,6 +6,7 @@ #define COBRA_ONLY // comment out for ccapi/non-cobra release #define REX_ONLY // shortcuts for REBUG REX CFWs / comment out for usual CFW +#define FULL_EDITION #define PS3MAPI // ps3 manager API & webGUI by _NzV_ //#define LITE_EDITION // no ps3netsrv support, smaller memory footprint diff --git a/flags/flags_full.h b/flags/flags_full.h index 52328560..1e625155 100644 --- a/flags/flags_full.h +++ b/flags/flags_full.h @@ -6,6 +6,7 @@ #define COBRA_ONLY // comment out for ccapi/non-cobra release #define REX_ONLY // shortcuts for REBUG REX CFWs / comment out for usual CFW +#define FULL_EDITION #define PS3MAPI // ps3 manager API & webGUI by _NzV_ //#define LITE_EDITION // no ps3netsrv support, smaller memory footprint diff --git a/flags/flags_lite.h b/flags/flags_lite.h index 2860d734..6e9eb287 100644 --- a/flags/flags_lite.h +++ b/flags/flags_lite.h @@ -39,7 +39,6 @@ #define ARTEMIS_PRX //// EXTRA FEATURES //// -//#define AUTO_TOGGLE_ON_XMB // auto switch to full edition (L1+R1+TRIANGLE) when a game returns to XMB //#define GET_KLICENSEE // /klic.ps3 //#define XMB_SCREENSHOT // screenshot XMB using L2 + R2 + SELECT + START (thanks to 3141card) //#define SWAP_KERNEL // load custom lv2_kernel.self patching LV1 and soft rebooting (use /copy.ps3) [requires QA flag enabled] @@ -55,6 +54,7 @@ //#define PHOTO_GUI // PhotoGUI: mount games through Photo column //#define MOUNT_PNG // support fake PNG as ISO //#define VISUALIZERS // Rotate visualizers (earth, lines, canyon, coldboot_*.ac3) +//#define AUTO_TOGGLE_ON_XMB // auto switch to full edition (L1+R1+TRIANGLE) when a game returns to XMB //// INTERNAL PLUGINS //// //#define USE_INTERNAL_NET_PLUGIN // comment out to use netiso.sprx diff --git a/include/cmd/artemis.h b/include/cmd/artemis.h index 3cd44d95..82c3223d 100644 --- a/include/cmd/artemis.h +++ b/include/cmd/artemis.h @@ -21,7 +21,7 @@ if((*code_list != '/') || strstr(code_list, ".ncl")) code_list = ARTEMIS_CODES_FILE; - sprintf(param, "%s%s", "/edit.ps3", code_list); + concat2(param, "/edit.ps3", code_list); start_artemis(); sys_ppu_thread_sleep(1); diff --git a/include/cmd/cpy_cut_paste.h b/include/cmd/cpy_cut_paste.h index 91305333..9445043d 100644 --- a/include/cmd/cpy_cut_paste.h +++ b/include/cmd/cpy_cut_paste.h @@ -4,7 +4,7 @@ // /cut.ps3 stores in clipboard buffer for move with /paste.ps3 (cp_mode = 2) cp_mode = islike(param, "/cut.ps3") ? CP_MODE_MOVE : CP_MODE_COPY; - snprintf(cp_path, STD_PATH_LEN, "%s", param + 8); + strncopy(cp_path, STD_PATH_LEN, param + 8); check_path_alias(cp_path); if(not_exists(cp_path) && !islike(cp_path, "/net")) cp_mode = CP_MODE_NONE; diff --git a/include/cmd/edit_chat_popup.h b/include/cmd/edit_chat_popup.h index 3f4a92d7..a0c7b905 100644 --- a/include/cmd/edit_chat_popup.h +++ b/include/cmd/edit_chat_popup.h @@ -15,14 +15,14 @@ if(*filename != '/') { - sprintf(filename, "/dev_hdd0/boot_plugins.txt"); // default file + strcopy(filename, "/dev_hdd0/boot_plugins.txt"); // default file } char *pos = strstr(param, "&t="); if(pos) { // backup the original text file - sprintf(backup, "%s.bak", filename); + concat2(backup, filename, ".bak"); rename_file(filename, backup); // replace previous backup // save text file @@ -116,7 +116,7 @@ show_msg(msg); if(mode=='=') - sbuffer.size = sprintf(sbuffer.str, "%s", msg); // raw mode + sbuffer.size = strcopy(sbuffer.str, msg); // raw mode else if(op) _concat(&sbuffer, msg); else diff --git a/include/cmd/err.h b/include/cmd/err.h new file mode 100644 index 00000000..1f5d553c --- /dev/null +++ b/include/cmd/err.h @@ -0,0 +1,14 @@ +#ifdef FULL_EDITION + if(islike(param, "/err.ps3")) + { + char *params = param + 9, *buffer = header; + + int errnum = val(params); + + sprintf(buffer, "Error 0x%x: %s", errnum, strerror(errnum)); + + keep_alive = http_response(conn_s, param, "/err.ps3", CODE_HTTP_OK, buffer); + + goto exit_handleclient_www; + } +#endif diff --git a/include/cmd/games.h b/include/cmd/games.h index 517753e5..9d292184 100644 --- a/include/cmd/games.h +++ b/include/cmd/games.h @@ -8,11 +8,11 @@ mobile_mode = true; const char *params = param + 10; if(not_exists(MOBILE_HTML)) - {sprintf(param, "/index.ps3%s", params); mobile_mode = false;} + {concat2(param, "/index.ps3", params); mobile_mode = false;} else if(strstr(param, "?g=")) sprintf(param, MOBILE_HTML); else if(strchr(param, '?')) - sprintf(param, "/index.ps3%s", params); + concat2(param, "/index.ps3", params); else if(not_exists(GAMELIST_JS)) sprintf(param, "/index.ps3?mobile"); else diff --git a/include/cmd/install.h b/include/cmd/install.h index db872c4d..dde7b933 100644 --- a/include/cmd/install.h +++ b/include/cmd/install.h @@ -22,7 +22,7 @@ if(islike(pkg_file, "/net")) { - sprintf(param, "%s%s", "/mount_ps3", pkg_file); // use /mount.ps3 command to install the remote pkg + concat2(param, "/mount_ps3", pkg_file); // use /mount.ps3 command to install the remote pkg is_binary = WEB_COMMAND; goto html_response; } diff --git a/include/cmd/klic.h b/include/cmd/klic.h index 9e72feea..68c62529 100644 --- a/include/cmd/klic.h +++ b/include/cmd/klic.h @@ -47,7 +47,7 @@ get_game_info(); snprintf(buffer, 0x200, "%s %s" "KLicensee: %s
" "Content ID: %s
" - "File: %s

", + "File: %s

", _game_TitleID, _game_Title, kl, (char*)KLIC_CONTENT_ID, (char*)KLIC_PATH); } diff --git a/include/cmd/mount_copy.h b/include/cmd/mount_copy.h index ab09d70b..77dd2925 100644 --- a/include/cmd/mount_copy.h +++ b/include/cmd/mount_copy.h @@ -83,7 +83,7 @@ else if(!islike(params, "/net") && !islike(params, WMTMP)) { - strcpy(templn, params); + strcopy(templn, params); if(not_exists(params)) { find_slaunch_game(params, 10); // search in slaunch.bin diff --git a/include/cmd/mount_search.h b/include/cmd/mount_search.h index 4fe3ac11..00d601fd 100644 --- a/include/cmd/mount_search.h +++ b/include/cmd/mount_search.h @@ -3,7 +3,7 @@ if(islike(param, "/mount") && is_ntfs_path(param + 10)) { char *filename = param + 10; change_cue2iso(filename); - sprintf(header, "%s%s", filename, ".ntfs["); + concat2(header, filename, ".ntfs["); int flen = get_name(filename, header, GET_WMTMP); for(int i = 2; i < 9; i++) // "PS3ISO", "BDISO", "DVDISO", "PS2ISO", "PSXISO", "PSXGAMES", "PSPISO" diff --git a/include/cmd/pad_combo_play.h b/include/cmd/pad_combo_play.h index 4087f829..444b10cd 100644 --- a/include/cmd/pad_combo_play.h +++ b/include/cmd/pad_combo_play.h @@ -97,16 +97,16 @@ #ifdef COBRA_NON_LITE strcpy(header, params); params = (char*)header; if(_islike(params, "movian") || IS(params, "HTSS00003")) - {sprintf(params, "col=tv&seg=HTSS00003"); mount_unk = APP_GAME;} else - if(_islike(params, "remoteplay")){sprintf(params, "col=network&seg=seg_premo");} else - if(_islike(params, "retro")) {sprintf(params, "SSNE10000");} else - if(_islike(params, "multiman")) {sprintf(params, "BLES80608");} else - if(_islike(params, "rebug")) {sprintf(params, "RBGTLBOX2");} + {strcopy(params, "col=tv&seg=HTSS00003"); mount_unk = APP_GAME;} else + if(_islike(params, "remoteplay")){strcopy(params, "col=network&seg=seg_premo");} else + if(_islike(params, "retro")) {strcopy(params, "SSNE10000");} else + if(_islike(params, "multiman")) {strcopy(params, "BLES80608");} else + if(_islike(params, "rebug")) {strcopy(params, "RBGTLBOX2");} #endif #ifdef COBRA_ONLY char path[32]; - snprintf(path, 32, "%s%s", HDD0_GAME_DIR, params); + snprintf(path, sizeof(path), "%s%s", HDD0_GAME_DIR, params); if(*map_title_id && (*params == NULL)) { diff --git a/include/cmd/popup.h b/include/cmd/popup.h index 6d5a4974..44f51dfd 100644 --- a/include/cmd/popup.h +++ b/include/cmd/popup.h @@ -25,7 +25,7 @@ { show_persistent_popup = PERSIST; if(param[11]) - {is_custom_popup = true; snprintf(custom_popup_msg, 200, "%s", ¶m[11]);} + {is_custom_popup = true; strncopy(custom_popup_msg, 200, ¶m[11]);} else {show_info_popup = true; BEEP1;} // show persistent info ON } diff --git a/include/cmd/reloadxmb.h b/include/cmd/reloadxmb.h index 1ceadb73..6b7ab242 100644 --- a/include/cmd/reloadxmb.h +++ b/include/cmd/reloadxmb.h @@ -1,5 +1,5 @@ if(islike(param, "/reloadxmb.ps3") && refreshing_xml == 0) { reload_xmb(param[14]); - sprintf(param, "/index.ps3"); + strcopy(param, "/index.ps3"); } diff --git a/include/cmd/rename_swap_move.h b/include/cmd/rename_swap_move.h index 61ed4059..5031d854 100644 --- a/include/cmd/rename_swap_move.h +++ b/include/cmd/rename_swap_move.h @@ -59,7 +59,7 @@ #endif if((cmd_len == SWAP_CMD) && file_exists(source) && file_exists(dest)) { - sprintf(header, "%s.bak", source); + concat2(header, source, ".bak"); rename_file(source, header); rename_file(dest, source); rename_file(header, dest); diff --git a/include/cmd/scsi_inquire.h b/include/cmd/scsi_inquire.h deleted file mode 100644 index b524463c..00000000 --- a/include/cmd/scsi_inquire.h +++ /dev/null @@ -1,73 +0,0 @@ -static struct lv2_atapi_cmnd_block { - uint8_t pkt[0x20]; // packet command block - uint32_t pktlen; - uint32_t blocks; - uint32_t block_size; - uint32_t proto; // transfer mode - uint32_t in_out; // transfer direction - uint32_t unknown; -} __attribute__((packed)); - -static int sys_storage_send_atapi_command(uint32_t fd, struct lv2_atapi_cmnd_block *atapi_cmnd, uint8_t *buffer) -{ - uint64_t tag; - system_call_7(0x25C, fd, 1, (uint32_t) atapi_cmnd , sizeof (struct lv2_atapi_cmnd_block), (uint32_t) buffer, atapi_cmnd->block_size, (uint32_t) & tag); - return_to_user_prog(int); -} - -static void init_atapi_cmnd_block( struct lv2_atapi_cmnd_block *atapi_cmnd, uint32_t block_size, uint32_t proto, uint32_t type) { - memset(atapi_cmnd, 0, sizeof(struct lv2_atapi_cmnd_block)); - atapi_cmnd->pktlen = 12; // 0xC - atapi_cmnd->blocks = 1; - atapi_cmnd->block_size = block_size; /* transfer size is block_size * blocks */ - atapi_cmnd->proto = proto; - atapi_cmnd->in_out = type; -} - -static int ps3rom_lv2_get_inquiry(int fd, uint8_t *buffer) { - int res; - struct lv2_atapi_cmnd_block atapi_cmnd; - - init_atapi_cmnd_block(&atapi_cmnd, 0x3C, 1, 1); - atapi_cmnd.pkt[0] = 0x12; - atapi_cmnd.pkt[1] = 0; - atapi_cmnd.pkt[2] = 0; - atapi_cmnd.pkt[3] = 0; - atapi_cmnd.pkt[4] = 0x3C; - - res = sys_storage_send_atapi_command(fd, &atapi_cmnd, buffer); - return res; -} - -static void get_bdvd_info(char *dump_path) -{ - // open Blu Ray Drive - uint32_t fd; - int ret = sys_storage_open(BDVD_DRIVE, 0, &fd, 0); - if(ret) // ret != 0 - { - //printf("sys_storage_open failed (0x%x)...\n", ret); - return; - } - - uint8_t buf[0x38]; - memset(buf,0,0x38); - - // inquiry command - ret = ps3rom_lv2_get_inquiry(fd, buf); - if(ret) // ret != 0 - { - //printf("sys_storage_send_device_command failed (0x%x)...\n", ret); - return; - } - - // close device - sys_storage_close(fd); - - - if(!dump_path || *dump_path != '/') - sprintf(dump_path, "/dev_hdd0/dump_inquire.bin"); - - // dump result to file - save_file(dump_path, (const char *)(buf+8), 0x30); -} diff --git a/include/cmd/secureid.h b/include/cmd/secureid.h index d60cb0d3..be684f58 100644 --- a/include/cmd/secureid.h +++ b/include/cmd/secureid.h @@ -4,8 +4,8 @@ hook_savedata_plugin(); sprintf(param, "Save data plugin: %s", securfileid_hooked ? STR_ENABLED : STR_DISABLED); - if(file_exists("/dev_hdd0/secureid.log") {sprintf(header, HTML_URL, "/dev_hdd0/secureid.log", "/dev_hdd0/secureid.log"); strcat(param, "

Download: "); strcat(param, header);} - + if(file_exists("/dev_hdd0/secureid.log") concat2(param, "

Download: ", strfmt(HTML_URL, "/dev_hdd0/secureid.log", "/dev_hdd0/secureid.log")); + keep_alive = http_response(conn_s, header, param, CODE_HTTP_OK, param); goto exit_handleclient_www; } diff --git a/include/cmd/view.h b/include/cmd/view.h index f9848608..07415ce9 100644 --- a/include/cmd/view.h +++ b/include/cmd/view.h @@ -12,7 +12,7 @@ // backup original PARAM.SFO if(patch) - {sprintf(out, "%s.bak", filename); save_file(out, param_sfo, sfo_size);} + {concat2(out, filename, ".bak"); save_file(out, param_sfo, sfo_size);} // add header & style sheet sprintf(tmp, "", HTML_URL_STYLE); diff --git a/include/cmd/write_trunc_unzip.h b/include/cmd/write_trunc_unzip.h index b4888ad7..ee8cb86c 100644 --- a/include/cmd/write_trunc_unzip.h +++ b/include/cmd/write_trunc_unzip.h @@ -39,7 +39,7 @@ if(isHEX(data)) size = Hex2Bin(data, header); else - size = sprintf(header, "%s", data); + size = strcopy(header, data); write_file(filename, CELL_FS_O_CREAT | CELL_FS_O_WRONLY, header, offset, size, false); diff --git a/include/cmd/xmb_browser.h b/include/cmd/xmb_browser.h index e60c742a..524d44bb 100644 --- a/include/cmd/xmb_browser.h +++ b/include/cmd/xmb_browser.h @@ -319,9 +319,9 @@ if(IS_ON_XMB || *params == '?' || *params == '/') { // in-XMB #ifdef COBRA_ONLY - if(islike(params, "$vsh_menu")) {start_vsh_gui(true); sprintf(param, "/cpursx.ps3"); goto html_response;} + if(islike(params, "$vsh_menu")) {start_vsh_gui(true); strcopy(param, "/cpursx.ps3"); goto html_response;} else - if(islike(params, "$slaunch")) {start_vsh_gui(false); sprintf(param, "/cpursx.ps3"); goto html_response;} + if(islike(params, "$slaunch")) {start_vsh_gui(false); strcopy(param, "/cpursx.ps3"); goto html_response;} else #endif #ifdef XMB_SCREENSHOT @@ -349,7 +349,7 @@ #endif { #ifndef LITE_EDITION - if(*params == NULL) sprintf(params, "/"); + if(*params == NULL) strcopy(params, "/"); if(*params == '/' ) {do_umount(false); check_path_alias(params); from_xmb_ps3 = true; sprintf(header, "http://%s%s", local_ip, params); open_browser(header, 0);} else if(*params == '$' ) {if(get_explore_interface()) exec_xmb_command(url);} else if(*params == '?' ) {do_umount(false); open_browser(url, 0);} else @@ -360,7 +360,7 @@ } } else - sprintf(url, "ERROR: Not in XMB!"); + strcopy(url, "ERROR: Not in XMB!"); if(!mc) keep_alive = http_response(conn_s, header, param, CODE_HTTP_OK, url); diff --git a/include/cpursx.h b/include/cpursx.h index 247d10c3..00548f93 100644 --- a/include/cpursx.h +++ b/include/cpursx.h @@ -61,16 +61,16 @@ static void get_cobra_version(char *cfw_info) if(!cobra_version) {char *cfw = strchr(cfw_info, ' '); *cfw = NULL;} #elif defined(DEX_SUPPORT) #if defined(DECR_SUPPORT) - sprintf(cfw_info, "%s", IS_DEH ? "DECR" : dex_mode ? "DEX" : "CEX"); + strcopy(cfw_info, IS_DEH ? "DECR" : dex_mode ? "DEX" : "CEX"); #else - sprintf(cfw_info, "%s", dex_mode ? "DEX" : "CEX"); + strcopy(cfw_info, dex_mode ? "DEX" : "CEX"); #endif if(pex_mode) *cfw_info = 'P'; #else - sprintf(cfw_info, "CEX"); + strcopy(cfw_info, "CEX"); #endif #ifndef COBRA_ONLY - sprintf(cfw_info, " nonCobra"); + strcopy(cfw_info, " nonCobra"); #endif // noBD LV1 4.75 - 4.91 @@ -183,7 +183,7 @@ static void get_sys_info(char *msg, u8 op, bool nolabel) if(op == 19) // temp {char *p = strchr(msg, '\n'); _memset(p, len-30); return;} if(op == 20) // fan mode - {sprintf(msg, "%s", fan_mode + 3); return;} + {strcopy(msg, fan_mode + 3); return;} #endif if(op == 21) // Startup time sprintf(msg, "%s: %s%02d:%02d:%02d", "Startup", days, hh, mm, ss); @@ -244,7 +244,7 @@ static void get_sys_info(char *msg, u8 op, bool nolabel) if(nolabel) { char *sep = strchr(msg, ':'); - if(sep) sprintf(msg, "%s", sep + 2); + if(sep) strcopy(msg, sep + 2); } else if(op == 34) replace_char(msg, ':', 'D'); return; @@ -333,9 +333,9 @@ static void qr_code(char *html, const char *url, const char *prefix, bool small, len = snprintf(text, 800, "http://%s%s", ip, url); } else if(*url == '?') - len = snprintf(text, 800, "%s", url + 1); + len = strncopy(text, 800, url + 1); else - len = snprintf(text, 800, "%s", url); + len = strncopy(text, 800, url); strcpy(text + len, "\");
"); @@ -343,7 +343,7 @@ static void qr_code(char *html, const char *url, const char *prefix, bool small, concat(buffer, html); else { - sz = sprintf(buffer, "%s", html); + sz = strcopy(buffer, html); // add caption text[len] = 0; diff --git a/include/feat/pkg_handler.h b/include/feat/pkg_handler.h index 18b6f108..0e1c9729 100644 --- a/include/feat/pkg_handler.h +++ b/include/feat/pkg_handler.h @@ -65,7 +65,7 @@ static u64 get_pkg_size_and_install_time(const char *pkgfile) { if(cellFsRead(fd, (void *)&pkg_header, sizeof(pkg_header), NULL) == CELL_FS_SUCCEEDED && pkg_header.magic == PKG_MAGIC) { - sprintf(install_path, "%s%s%s", HDD0_GAME_DIR, pkg_header.title_id, "/PS3LOGO.DAT"); + concat3(install_path, HDD0_GAME_DIR, pkg_header.title_id, "/PS3LOGO.DAT"); struct CellFsStat s; if(cellFsStat(install_path, &s) == CELL_FS_SUCCEEDED) pkg_install_time = s.st_mtime; // prevents pkg deletion if user cancels install @@ -227,20 +227,20 @@ static int download_file(const char *param, char *msg) if(!net_enabled) { - sprintf(msg, "ERROR: %s", "network disabled"); + concat2(msg, "ERROR: ", "network disabled"); return ret; } if(IS_INGAME) { - sprintf(msg, "ERROR: %s", "download from XMB"); + concat2(msg, "ERROR: ", "download from XMB"); return ret; } char *msg_durl = msg; char *msg_dpath = msg + MAX_URL_LEN + 16; - sprintf(msg_durl, "ERROR: %s", "Invalid URL"); + concat2(msg_durl, "ERROR: ", "Invalid URL"); sprintf(msg_dpath, "Download canceled"); char pdurl[MAX_URL_LEN]; @@ -268,7 +268,7 @@ static int download_file(const char *param, char *msg) len = get_param("?url=", pdurl, param, MAX_DLPATH_LEN); if(!islike(pdurl, "http")) goto end_download_process; conv_num = mbstowcs((wchar_t *)pkg_durl,(const char *)pdurl, len + 1); //size_t stdc_FCAC2E8E(wchar_t *dest, const char *src, size_t max) - len = sprintf(pdpath, "%s", is_ext(pdurl, ".p3t") ? "/dev_hdd0/theme" : DEFAULT_PKG_PATH); + len = strcopy(pdpath, is_ext(pdurl, ".p3t") ? "/dev_hdd0/theme" : DEFAULT_PKG_PATH); } if(conv_num) @@ -310,7 +310,7 @@ static int download_file(const char *param, char *msg) ret = CELL_OK; } else - sprintf(msg_durl, "ERROR: %s", "Setting storage location"); + concat2(msg_durl, "ERROR: ", "Setting storage location"); } end_download_process: @@ -344,7 +344,7 @@ static int installPKG(const char *pkgpath, char *msg) if(IS_INGAME) { - sprintf(msg, "ERROR: %s", "install from XMB"); + concat2(msg, "ERROR: ", "install from XMB"); return ret; } } @@ -366,7 +366,7 @@ static int installPKG(const char *pkgpath, char *msg) return download_file(pkgpath, msg); } else - snprintf(pkg_path, MAX_PKGPATH_LEN, "%s", pkgpath); + strncopy(pkg_path, MAX_PKGPATH_LEN, pkgpath); if(file_exists(pkg_path)) { @@ -383,7 +383,7 @@ static int installPKG(const char *pkgpath, char *msg) } } - if(ret) sprintf(msg, "ERROR: %s", pkgpath); + if(ret) concat2(msg, "ERROR: ", pkgpath); return ret; } @@ -456,13 +456,13 @@ static void poll_downloaded_pkg_files(char *msg) { char *dlfile = msg; - int plen = sprintf(dlfile, "%s", TEMP_DOWNLOAD_PATH); + int plen = strcopy(dlfile, TEMP_DOWNLOAD_PATH); while(working && (cellFsReaddir(fd, &entry, &read_e) == CELL_FS_SUCCEEDED) && (read_e > 0)) { if(is_ext(entry.d_name, ".pkg")) { - sprintf(dlfile + plen, "%s", entry.d_name); pkg_count++; + strcopy(dlfile + plen, entry.d_name); pkg_count++; cellFsChmod(dlfile, MODE); u64 pkg_size = get_pkg_size_and_install_time(dlfile); if(pkg_size == 0) continue; @@ -471,7 +471,7 @@ static void poll_downloaded_pkg_files(char *msg) if(cellFsStat(dlfile, &s) == CELL_FS_SUCCEEDED && pkg_size == s.st_size) { char pkgfile[MAX_PATH_LEN]; - u16 pkg_len = sprintf(pkgfile, "%s%s", DEFAULT_PKG_PATH, entry.d_name); + u16 pkg_len = concat2(pkgfile, DEFAULT_PKG_PATH, entry.d_name); for(u8 retry = 1; retry < 255; retry++) { if(cellFsRename(dlfile, pkgfile) == CELL_FS_SUCCEEDED) break; diff --git a/include/feat/script.h b/include/feat/script.h index de7c8645..0bae2487 100644 --- a/include/feat/script.h +++ b/include/feat/script.h @@ -282,7 +282,7 @@ static bool do_custom_combo(const char *filename) char combo_file[128]; if(*filename == '/') - snprintf(combo_file, sizeof(combo_file), "%s", filename); + strncopy(combo_file, sizeof(combo_file), filename); else snprintf(combo_file, sizeof(combo_file), "%s%s", WM_CUSTOM_COMBO, filename); // use default path #else diff --git a/include/feat/scsi_info.h b/include/feat/scsi_info.h index 1f0d5562..3c3b44ec 100644 --- a/include/feat/scsi_info.h +++ b/include/feat/scsi_info.h @@ -58,7 +58,7 @@ static void get_bdvd_info(const char *dump_path, char *buffer) ret = ps3rom_lv2_get_inquiry(fd, buf); if(ret != 0) { - sprintf(buffer, "sys_storage_send_device_command failed (0x%x)", ret); + sprintf(buffer, "sys_storage_send_atapi_command failed (0x%x)", ret); return; } diff --git a/include/feat/video_rec.h b/include/feat/video_rec.h index 682cfd0d..e2ea34ec 100644 --- a/include/feat/video_rec.h +++ b/include/feat/video_rec.h @@ -93,58 +93,58 @@ static void show_rec_format(const char *msg) sprintf(text, "%s\nVideo: ", msg); u32 flags = (rec_video_format & 0xF000); // video format - if(flags == 0x0000) concat(text, "MPEG4 "); else - if(flags == 0x1000) concat(text, "AVC MP "); else - if(flags == 0x2000) concat(text, "AVC BL "); else - if(flags == 0x3000) concat(text, "MJPEG "); else + if(flags == 0x0000) concat(text, "MPEG4 "); + if(flags == 0x1000) concat(text, "AVC MP "); + if(flags == 0x2000) concat(text, "AVC BL "); + if(flags == 0x3000) concat(text, "MJPEG "); if(flags == 0x4000) concat(text, "M4HD "); flags = (rec_video_format & 0xF00); // video size - if(flags == 0x000) concat(text, "240p @ "); else - if(flags == 0x100) concat(text, "272p @ "); else - if(flags == 0x200) concat(text, "368p @ "); else - if(flags == 0x300) concat(text, "480p @ "); else - if(flags == 0x600) concat(text, "720p @ "); + if(flags == 0x000) concat(text, strfmt("%ip @ ", 240)); + if(flags == 0x100) concat(text, strfmt("%ip @ ", 272)); + if(flags == 0x200) concat(text, strfmt("%ip @ ", 368)); + if(flags == 0x300) concat(text, strfmt("%ip @ ", 480)); + if(flags == 0x600) concat(text, strfmt("%ip @ ", 720)); //if(flags == 0x700) concat(text, "1080p @ "); flags = (rec_video_format & 0xF0); // video bitrate - if(flags == 0x00) concat(text, "512K"); else - if(flags == 0x10) concat(text, "768K"); else - if(flags == 0x20) concat(text, "1024K"); else - if(flags == 0x30) concat(text, "1536K"); else - if(flags == 0x40) concat(text, "2048K"); else - if(flags == 0x60) concat(text, "5000K"); else - if(flags == 0x70) concat(text, "11000K"); else - if(flags == 0x80) concat(text, "20000K"); else - if(flags == 0x90) concat(text, "25000K"); + if(flags == 0x00) concat(text, strfmt("%iK", 512)); + if(flags == 0x10) concat(text, strfmt("%iK", 768)); + if(flags == 0x20) concat(text, strfmt("%iK", 1024)); + if(flags == 0x30) concat(text, strfmt("%iK", 1536)); + if(flags == 0x40) concat(text, strfmt("%iK", 2048)); + if(flags == 0x60) concat(text, strfmt("%iK", 5000)); + if(flags == 0x70) concat(text, strfmt("%iK", 11000)); + if(flags == 0x80) concat(text, strfmt("%iK", 20000)); + if(flags == 0x90) concat(text, strfmt("%iK", 25000)); //if(flags == 0xA0) concat(text, "30000K"); concat(text, "\nAudio: "); // audio format flags = (rec_audio_format & 0xF000); - if(flags == 0x0000) concat(text, "AAC "); else - if(flags == 0x1000) concat(text, "ULAW "); else + if(flags == 0x0000) concat(text, "AAC "); + if(flags == 0x1000) concat(text, "ULAW "); if(flags == 0x2000) concat(text, "PCM "); flags = (rec_audio_format & 0xF); // audio bitrate - if(flags == 0x0) concat(text, "96K"); else - if(flags == 0x1) concat(text, "128K"); else - if(flags == 0x2) concat(text, "64K"); else - if(flags == 0x7) concat(text, "384K"); else - if(flags == 0x8) concat(text, "768K"); else - if(flags == 0x9) concat(text, "1536K"); + if(flags == 0x0) concat(text, strfmt("%iK", 96)); + if(flags == 0x1) concat(text, strfmt("%iK", 128)); + if(flags == 0x2) concat(text, strfmt("%iK", 64)); + if(flags == 0x7) concat(text, strfmt("%iK", 384)); + if(flags == 0x8) concat(text, strfmt("%iK", 768)); + if(flags == 0x9) concat(text, strfmt("%iK", 1536)); show_msg(text); } static void set_setting_to_change(char *msg, const char *text) { - sprintf(msg, "%s", text); - if(rec_setting_to_change == 0) concat(msg, "Recording Options"); else - if(rec_setting_to_change == 1) concat(msg, "Video Format"); else - if(rec_setting_to_change == 2) concat(msg, "Video Size"); else - if(rec_setting_to_change == 3) concat(msg, "Video Bitrate"); else - if(rec_setting_to_change == 4) concat(msg, "Audio Format"); else + strcopy(msg, text); + if(rec_setting_to_change == 0) concat(msg, "Recording Options"); + if(rec_setting_to_change == 1) concat(msg, "Video Format"); + if(rec_setting_to_change == 2) concat(msg, "Video Size"); + if(rec_setting_to_change == 3) concat(msg, "Video Bitrate"); + if(rec_setting_to_change == 4) concat(msg, "Audio Format"); if(rec_setting_to_change == 5) concat(msg, "Audio Bitrate"); } @@ -183,9 +183,9 @@ static bool rec_start(const char *param) { rec_video_format = CELL_REC_PARAM_VIDEO_FMT_M4HD_HD720_5000K_30FPS; // .mp4 (720p) - if(strstr(param, "240")) rec_video_format = CELL_REC_PARAM_VIDEO_FMT_MPEG4_SMALL_768K_30FPS; // .mp4 (240p / 208p) - if(strstr(param, "272")) rec_video_format = CELL_REC_PARAM_VIDEO_FMT_MPEG4_MIDDLE_768K_30FPS; // .mp4 (272p) - if(strstr(param, "368")) rec_video_format = CELL_REC_PARAM_VIDEO_FMT_MPEG4_LARGE_2048K_30FPS; // .mp4 (368p) + if(strnum(param, 240)) rec_video_format = CELL_REC_PARAM_VIDEO_FMT_MPEG4_SMALL_768K_30FPS; // .mp4 (240p / 208p) + if(strnum(param, 272)) rec_video_format = CELL_REC_PARAM_VIDEO_FMT_MPEG4_MIDDLE_768K_30FPS; // .mp4 (272p) + if(strnum(param, 368)) rec_video_format = CELL_REC_PARAM_VIDEO_FMT_MPEG4_LARGE_2048K_30FPS; // .mp4 (368p) } if(strcasestr(param, "jpeg")) {rec_video_format = CELL_REC_PARAM_VIDEO_FMT_YOUTUBE_MJPEG; rec_audio_format = CELL_REC_PARAM_AUDIO_FMT_YOUTUBE_MJPEG;} // mjpeg @@ -200,18 +200,18 @@ static bool rec_start(const char *param) { rec_video_format = CELL_REC_PARAM_VIDEO_FMT_M4HD_HD720_11000K_30FPS; // hd (11000k) - if(strstr(param, "768")) rec_video_format = CELL_REC_PARAM_VIDEO_FMT_M4HD_MIDDLE_768K_30FPS; // hd 768k (272p) - if(strstr(param, "1536")) rec_video_format = CELL_REC_PARAM_VIDEO_FMT_M4HD_LARGE_1536K_30FPS; // hd 1536k (368p) - if(strstr(param, "2048")) rec_video_format = CELL_REC_PARAM_VIDEO_FMT_M4HD_HD720_2048K_30FPS; // hd 2048k (720p) + if(strnum(param, 768)) rec_video_format = CELL_REC_PARAM_VIDEO_FMT_M4HD_MIDDLE_768K_30FPS; // hd 768k (272p) + if(strnum(param, 1536)) rec_video_format = CELL_REC_PARAM_VIDEO_FMT_M4HD_LARGE_1536K_30FPS; // hd 1536k (368p) + if(strnum(param, 2048)) rec_video_format = CELL_REC_PARAM_VIDEO_FMT_M4HD_HD720_2048K_30FPS; // hd 2048k (720p) } else { if(strcasestr(param, "avc")) rec_video_format = CELL_REC_PARAM_VIDEO_FMT_AVC_MP_MIDDLE_768K_30FPS; // avc (psp/ps3) - if(strstr(param, "512")) rec_video_format = CELL_REC_PARAM_VIDEO_FMT_AVC_MP_MIDDLE_512K_30FPS; // avc 512k - if(strstr(param, "768")) rec_video_format = CELL_REC_PARAM_VIDEO_FMT_AVC_MP_MIDDLE_768K_30FPS; // avc 768k - if(strstr(param, "1024")) rec_video_format = CELL_REC_PARAM_VIDEO_FMT_AVC_MP_MIDDLE_1024K_30FPS; // avc 1024k - if(strstr(param, "1536")) rec_video_format = CELL_REC_PARAM_VIDEO_FMT_AVC_MP_MIDDLE_1536K_30FPS; // avc 1536k + if(strnum(param, 512)) rec_video_format = CELL_REC_PARAM_VIDEO_FMT_AVC_MP_MIDDLE_512K_30FPS; // avc 512k + if(strnum(param, 768)) rec_video_format = CELL_REC_PARAM_VIDEO_FMT_AVC_MP_MIDDLE_768K_30FPS; // avc 768k + if(strnum(param, 1024)) rec_video_format = CELL_REC_PARAM_VIDEO_FMT_AVC_MP_MIDDLE_1024K_30FPS; // avc 1024k + if(strnum(param, 1536)) rec_video_format = CELL_REC_PARAM_VIDEO_FMT_AVC_MP_MIDDLE_1536K_30FPS; // avc 1536k } } @@ -231,15 +231,15 @@ static bool rec_start(const char *param) if(strcasestr(param, "aac")) { rec_audio_format = CELL_REC_PARAM_AUDIO_FMT_AAC_96K; // aac_96k - if(strstr(param, "64")) rec_audio_format = CELL_REC_PARAM_AUDIO_FMT_AAC_64K; // aac_64k - if(strstr(param, "128")) rec_audio_format = CELL_REC_PARAM_AUDIO_FMT_AAC_128K; // aac_128k + if(strnum(param, 64)) rec_audio_format = CELL_REC_PARAM_AUDIO_FMT_AAC_64K; // aac_64k + if(strnum(param, 128)) rec_audio_format = CELL_REC_PARAM_AUDIO_FMT_AAC_128K; // aac_128k } else if(strcasestr(param, "pcm")) { rec_audio_format = CELL_REC_PARAM_AUDIO_FMT_PCM_768K; // pcm_768k - if(strstr(param, "384")) rec_audio_format = CELL_REC_PARAM_AUDIO_FMT_PCM_384K; // pcm_384k - if(strstr(param, "1536")) rec_audio_format = CELL_REC_PARAM_AUDIO_FMT_PCM_1536K; // pcm_1536k + if(strnum(param, 384)) rec_audio_format = CELL_REC_PARAM_AUDIO_FMT_PCM_384K; // pcm_384k + if(strnum(param, 1536)) rec_audio_format = CELL_REC_PARAM_AUDIO_FMT_PCM_1536K; // pcm_1536k } // validate audio format (use default if invalid) diff --git a/include/feat/vsh_random_res.h b/include/feat/vsh_random_res.h index 68a71235..655d571e 100644 --- a/include/feat/vsh_random_res.h +++ b/include/feat/vsh_random_res.h @@ -15,13 +15,13 @@ static u8 map_vsh_resource(u8 res_id, u8 id, char *param, u8 set) (res_id == 9) ? "/dev_hdd0/tmp/system_plugin": // 9 "/dev_hdd0/tmp/theme"; // 5 & 6 (last selected theme) - const char *res_path = (res_id == 1) ? "/dev_flash/vsh/resource/qgl/earth.qrc" : - (res_id == 2) ? "/dev_flash/vsh/resource/qgl/canyon.qrc": - (res_id == 3) ? "/dev_flash/vsh/resource/qgl/lines.qrc" : - (res_id == 4) ? "/dev_flash/vsh/resource/coldboot_stereo.ac3": - (res_id == 8) ? "/dev_flash/vsh/resource/xmb_plugin_normal.rco": - (res_id == 9) ? "/dev_flash/vsh/resource/system_plugin.rco": - "/dev_flash/vsh/resource/impose_plugin.rco"; // 7 + const char *res_path = (res_id == 1) ? "qgl/earth.qrc" : + (res_id == 2) ? "qgl/canyon.qrc": + (res_id == 3) ? "qgl/lines.qrc" : + (res_id == 4) ? "coldboot_stereo.ac3": + (res_id == 8) ? "xmb_plugin_normal.rco": + (res_id == 9) ? "system_plugin.rco": + "impose_plugin.rco"; // 7 if(isDir(hdd_path)) { @@ -91,7 +91,7 @@ static u8 map_vsh_resource(u8 res_id, u8 id, char *param, u8 set) } else if(res_id) { - sys_map_path(res_path, param); + sys_map_path(strfmt("%s%s", VSH_RESOURCE_DIR, res_path), param); if(res_id == 4) sys_map_path("/dev_flash/vsh/resource/coldboot_multi.ac3", param); if(res_id == 8) @@ -117,7 +117,7 @@ static u8 map_vsh_resource(u8 res_id, u8 id, char *param, u8 set) if(res_id == 5) webman_config->resource_id[6] = 0; // reset last selected theme else - strcpy(param, res_path); + concat2(param, VSH_RESOURCE_DIR, res_path); unmap_path(param); } diff --git a/include/file/file.h b/include/file/file.h index 15d3938a..3833089b 100644 --- a/include/file/file.h +++ b/include/file/file.h @@ -44,8 +44,8 @@ static bool file_exists(const char *path) static bool is_app_dir(const char *path, const char *app_name) { - char eboot[STD_PATH_LEN + 1]; - snprintf(eboot, STD_PATH_LEN, "%s/%s/USRDIR/EBOOT.BIN", path, app_name); + char eboot[STD_PATH_LEN]; + snprintf(eboot, STD_PATH_LEN, "%s/%s%s", path, app_name, "/USRDIR/EBOOT.BIN"); return file_exists(eboot); } @@ -185,14 +185,14 @@ static void check_path_alias(char *param) if(strstr(param, ".ps3")) return; char path[STD_PATH_LEN]; - int len = snprintf(path, STD_PATH_LEN - 1, "%s", (*param == '/') ? param + 1 : param); + int len = strncopy(path, STD_PATH_LEN, (*param == '/') ? param + 1 : param); char *wildcard = strchr(path, '*'); if(wildcard) *wildcard = 0; if((len == 4) && path[3] == '/') path[3] = 0; // normalize path if(IS(path, "pkg")) {sprintf(param, DEFAULT_PKG_PATH);} else if(IS(path, "xml")) {*path = 0;} else // use HTML_BASE_PATH - if(IS(path, "xmb")) {enable_dev_blind(NULL); sprintf(param, "/dev_blind/vsh/resource/explore/xmb");} else - if(IS(path, "res")) {enable_dev_blind(NULL); sprintf(param, "/dev_blind/vsh/resource");} else - if(IS(path, "mod")) {enable_dev_blind(NULL); sprintf(param, "/dev_blind/vsh/module");} else + if(IS(path, "xmb")) {enable_dev_blind(NULL); strcopy(param, "/dev_blind/vsh/resource/explore/xmb");} else + if(IS(path, "res")) {enable_dev_blind(NULL); strcopy(param, "/dev_blind/vsh/resource");} else + if(IS(path, "mod")) {enable_dev_blind(NULL); strcopy(param, "/dev_blind/vsh/module");} else if(IS(path, "cov")) {sprintf(param, "%s/covers", MM_ROOT_STD);} else if(IS(path, "cvr")) {sprintf(param, "%s/covers_retro/psx", MM_ROOT_STD);} else if(islike(path, "res/")) {sprintf(param, "/dev_blind/vsh/resource/%s", path + 4);} else @@ -227,19 +227,7 @@ static void check_path_alias(char *param) static bool is_empty_dir(const char *path) { - int fd; bool ret = true; - if(cellFsOpendir(path, &fd) == CELL_FS_SUCCEEDED) - { - CellFsDirectoryEntry entry; size_t read_e; - while(working) - { - if(cellFsGetDirectoryEntries(fd, &entry, sizeof(entry), &read_e) || !read_e) break; - if(entry.entry_name.d_name[0] == '.') continue; - ret = false; break; - } - cellFsClosedir(fd); - } - return ret; + return folder_count(path, 1) == 0; } #if defined(COPY_PS3) || defined(PKG_HANDLER) || defined(MOUNT_GAMEI) diff --git a/include/file/file_copy.h b/include/file/file_copy.h index 48332a03..43bcc6ca 100644 --- a/include/file/file_copy.h +++ b/include/file/file_copy.h @@ -406,8 +406,8 @@ static int recursive_folder_copy(const char *path1, char *path2) char source[STD_PATH_LEN]; char target[STD_PATH_LEN]; - u16 plen1 = sprintf(source, "%s", path1); - u16 plen2 = sprintf(target, "%s", path2); + u16 plen1 = strcopy(source, path1); + u16 plen2 = strcopy(target, path2); while(working) { @@ -599,7 +599,7 @@ static void copy_rom_media(const char *src_path) // patch title name in PARAM.SFO of PKGLAUNCH char dst_path[64]; - sprintf(dst_path, "%s/PS3_GAME/%s", PKGLAUNCH_DIR, "PARAM.SFO"); + concat2(dst_path, PKGLAUNCH_DIR, "/PS3_GAME/PARAM.SFO"); patch_file(dst_path, title, 0x378, 0x80); const char *PS3_GAME[2] = { "/PS3_GAME", ""}; @@ -610,11 +610,11 @@ static void copy_rom_media(const char *src_path) for(u8 p = 0; p < 2; p++) { // copy rom icon to ICON0.PNG - sprintf(dst_path, "%s%s/%s", PKGLAUNCH_DIR, PS3_GAME[p], "ICON0.PNG"); + concat_path2(dst_path, PKGLAUNCH_DIR, PS3_GAME[p], "/ICON0.PNG"); {strcpy(ext, ".png"); if(file_exists(src_path)) {file_copy(src_path, dst_path);} else {strcpy(ext, ".PNG"); if(file_exists(src_path)) {file_copy(src_path, dst_path);} else { - sprintf(path, "%s/%s", WMTMP, name); + concat_path(path, WMTMP, name); char *ext2 = strrchr(path, '.'); {strcpy(ext2, ".png"); if(file_exists(path)) {file_copy(path, dst_path);} else {strcpy(ext2, ".PNG"); if(file_exists(path)) {file_copy(path, dst_path);} else @@ -623,10 +623,10 @@ static void copy_rom_media(const char *src_path) strcpy(path, src_path); char *path_ = get_filename(path) + 1; - const char *media[5] = {"PIC0.PNG", "PIC1.PNG", "PIC2.PNG", "SND0.AT3", "ICON1.PAM"}; + const char *media[5] = {"/PIC0.PNG", "/PIC1.PNG", "/PIC2.PNG", "/SND0.AT3", "/ICON1.PAM"}; for(u8 i = 0; i < 5; i++) { - sprintf(dst_path, "%s%s/%s", PKGLAUNCH_DIR, PS3_GAME[p], media[i]); cellFsUnlink(dst_path); + concat_path2(dst_path, PKGLAUNCH_DIR, PS3_GAME[p], media[i]); cellFsUnlink(dst_path); strcpy(ext + 1, media[i]); if(file_exists(src_path)) file_copy(src_path, dst_path); diff --git a/include/file/file_delete.h b/include/file/file_delete.h index b6558b8c..57cc64f8 100644 --- a/include/file/file_delete.h +++ b/include/file/file_delete.h @@ -100,7 +100,7 @@ static int del(const char *path, u8 recursive) static void unlink_file(const char *drive, const char *path, const char *file) { char filename[64]; - sprintf(filename, "%s/%s%s", drive, path, file); cellFsUnlink(filename); + concat_path2(filename, drive, path, file); cellFsUnlink(filename); } #ifndef LITE_EDITION @@ -165,7 +165,7 @@ static void uninstall(char *param) restore_fan(SYSCON_MODE); - sprintf(param, "%s%s", "/delete.ps3", "?uninstall"); + concat2(param, "/delete.ps3", "?uninstall"); } #endif @@ -195,7 +195,7 @@ static void delete_history(bool delete_folders) for(u8 p = 0; p < 10; p++) { - sprintf(path, "%s/%s", drives[0], paths[p]); cellFsRmdir(path); + concat_path(path, drives[0], paths[p]); cellFsRmdir(path); strcat(path, AUTOPLAY_TAG); cellFsRmdir(path); } cellFsRmdir("/dev_hdd0/PKG"); diff --git a/include/file/file_scan.h b/include/file/file_scan.h index 45d30c84..efc49bbf 100644 --- a/include/file/file_scan.h +++ b/include/file/file_scan.h @@ -88,11 +88,11 @@ static int scan(const char *path, u8 recursive, const char *wildcard, enum scan_ char entry[STD_PATH_LEN], dest_entry[STD_PATH_LEN]; - u16 path_len = sprintf(entry, "%s", path); + u16 path_len = strcopy(entry, path); bool p_slash = (path_len > 1) && (path[path_len - 1] == '/'); char *pentry = entry + path_len; - u16 dest_len = sprintf(dest_entry, "%s", dest); + u16 dest_len = strcopy(dest_entry, dest); char *pdest = dest_entry + dest_len; while(working) @@ -112,9 +112,9 @@ static int scan(const char *path, u8 recursive, const char *wildcard, enum scan_ if(copy_aborted) break; if(entry_name[0] == '.' && (entry_name[1] == '.' || entry_name[1] == '\0')) continue; - if(p_slash) sprintf(pentry, "%s", entry_name); else sprintf(pentry, "/%s", entry_name); + if(p_slash) strcopy(pentry, entry_name); else sprintf(pentry, "/%s", entry_name); - if(use_dest) sprintf(pdest, "/%s", entry_name); + if(use_dest) strcopy(pdest, entry_name); if(isDir(entry)) {if(recursive) scan(entry, recursive, wildcard, fop, dest);} @@ -154,7 +154,7 @@ static int scan(const char *path, u8 recursive, const char *wildcard, enum scan_ file_copy(entry, dest_entry); // copy ntfs & cellFS if((fop == SCAN_COPYBK) && file_exists(dest_entry)) - {sprintf(dest_entry, "%s.bak", entry); rename_file(entry, dest_entry);} + {concat2(dest_entry, entry, ".bak"); rename_file(entry, dest_entry);} } else if(prescan) counter++; // pre-count move/rename/delete operations diff --git a/include/file/file_size.h b/include/file/file_size.h index 674c2657..f42f6e74 100644 --- a/include/file/file_size.h +++ b/include/file/file_size.h @@ -65,7 +65,7 @@ static size_t size_link(const char *source) if(!islike(usrdir + 8, "EBOOT.BIN")) { char game_path[MAX_PATH_LEN]; - sprintf(game_path, "%s%s%s", _HDD0_GAME_DIR, stitle_id, usrdir); + concat3(game_path, _HDD0_GAME_DIR, stitle_id, usrdir); if(file_size(game_path) == size) { if(copy_aborted) return 0; @@ -132,7 +132,7 @@ static u64 folder_size(const char *path) char *entry_name = entry.entry_name.d_name; char source[STD_PATH_LEN]; - u16 plen1 = sprintf(source, "%s", path); + u16 plen1 = strcopy(source, path); char *psource = source + plen1; while(working) @@ -146,9 +146,10 @@ static u64 folder_size(const char *path) #endif if(cellFsGetDirectoryEntries(fd, &entry, sizeof(entry), &read_f) || !read_f) break; - if(copy_aborted) break; if(entry_name[0] == '.' && (entry_name[1] == '.' || entry_name[1] == '\0')) continue; + if(copy_aborted) break; + sprintf(psource, "/%s", entry_name); if(do_chmod) cellFsChmod(source, new_mode); if(isDir(source)) @@ -171,4 +172,30 @@ static u64 folder_size(const char *path) return dir_size; } -#endif // #ifdef COPY_PS3 \ No newline at end of file +#endif // #ifdef COPY_PS3 + +static int folder_count(const char *path, s8 max_items) +{ + int fd; + + int dir_items = 0; + + if(cellFsOpendir(path, &fd) == CELL_FS_SUCCEEDED) + { + CellFsDirectoryEntry entry; u32 read_f; + char *entry_name = entry.entry_name.d_name; + + while(working) + { + if(cellFsGetDirectoryEntries(fd, &entry, sizeof(entry), &read_f) || !read_f) break; + + if(entry_name[0] == '.') continue; + + if(++dir_items == max_items) break; // max_items: 1=is_dir_empty, 2=has_one_user_dir (2 or more), -1=folder count + } + + cellFsClosedir(fd); + } + + return dir_items; +} diff --git a/include/file/togglers.h b/include/file/togglers.h index 34d39c16..ca1348fc 100644 --- a/include/file/togglers.h +++ b/include/file/togglers.h @@ -71,17 +71,17 @@ static void swap_file(const char *path, const char *curfile, const char *rento, { char file1[64], file2[64]; - sprintf(file1, "%s%s%s", "/dev_flash", path + 10, newfile); + concat3(file1, "/dev_flash", path + 10, newfile); if(file_exists(file1)) { mount_device("/dev_blind", NULL, NULL); - sprintf(file1, "%s%s", path, curfile); + concat2(file1, path, curfile); - sprintf(file2, "%s%s", path, rento); + concat2(file2, path, rento); cellFsRename(file1, file2); - sprintf(file2, "%s%s", path, newfile); + concat2(file2, path, newfile); cellFsRename(file2, file1); } } diff --git a/include/file_manager.h b/include/file_manager.h index f3c827e0..7ffed22b 100644 --- a/include/file_manager.h +++ b/include/file_manager.h @@ -81,16 +81,16 @@ static int add_list_entry(char *param, int plen, char *tempstr, bool is_dir, cha if( !is_dir && IS(name, "PARAM.SFO") ) { char *html = tempstr; - char titleid[10], app_ver[8], title[128]; snprintf(title, 127, "%s", full_path); + char titleid[10], app_ver[8], title[128]; strncopy(title, sizeof(title), full_path); //get title & app app_ver from PARAM.SFO getTitleID(full_path, app_ver, GET_VERSION); getTitleID(title, titleid, GET_TITLE_AND_ID); get_flag(title, " ["); get_flag(title, "\n"); get_cover_from_name(tempstr, get_filename(param) + 1, titleid); // get title id from path (if title ID was not found in PARAM.SFO) if(*app_ver >= '0') {strcat(title, " v"); strcat(title, app_ver);} - sprintf(buf_path, "%s%s", HDD0_GAME_DIR, titleid); bool has_updates_dir = file_exists(buf_path); + concat2(buf_path, HDD0_GAME_DIR, titleid); bool has_updates_dir = file_exists(buf_path); - sprintf(html, " title=\"%s\">%s", title, name); snprintf(name, maxlen, "%s", html); + sprintf(html, " title=\"%s\">%s", title, name); strncopy(name, maxlen, html); is_param_sfo = ' '; ft = " cfg"; @@ -98,7 +98,7 @@ static int add_list_entry(char *param, int plen, char *tempstr, bool is_dir, cha if(has_updates_dir) snprintf(fsize, maxlen, HTML_URL2, HDD0_GAME_DIR, titleid, title); else - snprintf(fsize, maxlen, "%s", title); + strncopy(fsize, maxlen, title); // show title id & link to updates if(*titleid && !islike(titleid, "NPWR")) @@ -123,7 +123,7 @@ static int add_list_entry(char *param, int plen, char *tempstr, bool is_dir, cha // encode url for html // ///////////////////////// - if(urlenc(buf_path, full_path)) {buf_path[_MAX_LINE_LEN] = '\0'; sprintf(full_path, "%s", buf_path);} + if(urlenc(buf_path, full_path)) {buf_path[_MAX_LINE_LEN] = '\0'; strcopy(full_path, buf_path);} // is image? u8 show_img = (!is_dir && (_IS(ext, ".png") || _IS(ext, ".jpg") || _IS(ext, ".bmp"))); @@ -227,15 +227,15 @@ static int add_list_entry(char *param, int plen, char *tempstr, bool is_dir, cha } if(sys_admin && IS(full_path, "/dev_flash")) - sprintf(buf_path, "%s%s", "/dev_blind", "?1"); + concat2(buf_path, "/dev_blind", "?1"); else if(IS(full_path, "/dev_blind")) - sprintf(buf_path, "%s%s", "/dev_blind", "?0"); + concat2(buf_path, "/dev_blind", "?0"); #ifdef USE_NTFS else if(is_ntfs) - sprintf(buf_path, "%s%s", "/refresh.ps3", "?prepntfs"); + concat2(buf_path, "/refresh.ps3", "?prepntfs"); #endif else - sprintf(buf_path, "%s%s", "/mount.ps3", full_path); + concat2(buf_path, "/mount.ps3", full_path); // show graphic bar of device size & free space if(devSize > 0) @@ -417,14 +417,14 @@ static int add_list_entry(char *param, int plen, char *tempstr, bool is_dir, cha else { //if(*name == '0' && flen == 8 && IS(param, HDD0_HOME_DIR)) - // snprintf(ename, FILE_MGR_KEY_LEN, "%s", name + 3); + // strncopy(ename, FILE_MGR_KEY_LEN, name + 3); //else snprintf(ename, FILE_MGR_KEY_LEN, "%s ", name); sclass = dclass; if(flen > FILE_MGR_KEY_LEN -2) {char c = name[flen - 1]; if(ISDIGIT(c)) ename[FILE_MGR_KEY_LEN - 2] = c;} // sort isos } - if((plen > 1) && memcmp(full_path, param, plen) == 0) sprintf(full_path, "%s", full_path + plen + 1); // remove path from full_path (use relative path) + if((plen > 1) && memcmp(full_path, param, plen) == 0) strcopy(full_path, full_path + plen + 1); // remove path from full_path (use relative path) ////////////////////// @@ -475,7 +475,7 @@ static int add_list_entry(char *param, int plen, char *tempstr, bool is_dir, cha new_item += flen; // append size column - sprintf(new_item, "%s", html_sizecol); + strcopy(new_item, html_sizecol); // append date column (21 bytes) #ifdef CHECK_PSHOME @@ -532,8 +532,8 @@ static int add_breadcrumb_trail(char *pbuffer, const char *param) } // add link to file or folder - if(!param[1]) slen = sprintf(swap, "/"); - else if((param[1] != 'n') && not_exists(param)) slen = sprintf(swap, "%s", get_filename(param) + 1); + if(!param[1]) slen = strcopy(swap, "/"); + else if((param[1] != 'n') && not_exists(param)) slen = strcopy(swap, get_filename(param) + 1); else { char label[_MAX_PATH_LEN]; @@ -786,7 +786,7 @@ static bool folder_listing(char *buffer, u32 BUFFER_SIZE_HTML, char *html, char else if(dir_items[n].name[0] == '/') flen = sprintf(full_path, "%.5s%s", param, dir_items[n].name); else - flen = sprintf(full_path, "%s%s", param, dir_items[n].name); + flen = concat2(full_path, param, dir_items[n].name); normalize_path(full_path, false); @@ -905,7 +905,7 @@ static bool folder_listing(char *buffer, u32 BUFFER_SIZE_HTML, char *html, char } else { - flen = sprintf(full_path, "%s/%s", param, entry_name); + flen = concat_path(full_path, param, entry_name); } if(full_path[flen - 1] == '/') full_path[flen--] = '\0'; @@ -1018,19 +1018,19 @@ static bool folder_listing(char *buffer, u32 BUFFER_SIZE_HTML, char *html, char if(is_net && jb_games) { replace_char(param + 12, '/', 0); - sprintf(full_path, "%s/PS3_GAME/ICON0.PNG", param); + concat2(full_path, param, "/PS3_GAME/ICON0.PNG"); show_icon = true; } if(!show_icon) { - sprintf(full_path, "%s/ICON0.PNG", param); show_icon = file_exists(full_path); // current folder + concat_path(full_path, param, "ICON0.PNG"); show_icon = file_exists(full_path); // current folder if(!show_icon) sprintf(full_path, "%s/ICON2.PNG", param); show_icon = file_exists(full_path); // ps3_extra folder if(!show_icon) { replace_char(param + 18, '/', 0); - sprintf(full_path, "%s/PS3_GAME/ICON0.PNG", param); show_icon = file_exists(full_path); // dev_bdvd or jb folder - if(!show_icon) sprintf(full_path, "%s/ICON0.PNG", param); show_icon = file_exists(full_path); // game dir + concat2(full_path, param, "/PS3_GAME/ICON0.PNG"); show_icon = file_exists(full_path); // dev_bdvd or jb folder + if(!show_icon) concat_path(full_path, param, "ICON0.PNG"); show_icon = file_exists(full_path); // game dir } } @@ -1046,7 +1046,7 @@ static bool folder_listing(char *buffer, u32 BUFFER_SIZE_HTML, char *html, char if(iso_disctype == DISC_TYPE_DVD) dt = iDVD; #endif - sprintf(full_path, "%s", wm_icons[dt]); show_icon = true; + strcopy(full_path, wm_icons[dt]); show_icon = true; } for(u16 m = idx; m < 10; m++) _concat(&sout, "
"); diff --git a/include/ftp.h b/include/ftp.h index 8c7cad7e..ec176322 100644 --- a/include/ftp.h +++ b/include/ftp.h @@ -48,7 +48,7 @@ static u8 parsePath(char *absPath_s, const char *path, const char *cwd, bool sca if(*path == '/') { - sprintf(absPath_s, "%s", path); + strcopy(absPath_s, path); normalize_path(absPath_s, true); @@ -57,7 +57,7 @@ static u8 parsePath(char *absPath_s, const char *path, const char *cwd, bool sca } else { - u16 len = sprintf(absPath_s, "%s", cwd); + u16 len = strcopy(absPath_s, cwd); normalize_path(absPath_s, true); @@ -87,7 +87,7 @@ static u8 parsePath(char *absPath_s, const char *path, const char *cwd, bool sca } } else { // Path is absolute - snprintf(absPath_s, STD_PATH_LEN, "%s", path); + strncopy(absPath_s, STD_PATH_LEN, path); } } @@ -200,7 +200,7 @@ static void handleclient_ftp(u64 conn_s_ftp_p) sys_net_get_sockinfo(conn_s_ftp, &conn_info, 1); char remote_ip[16]; - sprintf(remote_ip, "%s", inet_ntoa(conn_info.remote_adr)); + strcopy(remote_ip, inet_ntoa(conn_info.remote_adr)); // check remote access if(webman_config->bind && is_remote_ip && !islike(remote_ip, webman_config->allow_ip)) @@ -217,7 +217,7 @@ static void handleclient_ftp(u64 conn_s_ftp_p) setPluginActive(); char ip_address[16]; - sprintf(ip_address, "%s", inet_ntoa(conn_info.local_adr)); + strcopy(ip_address, inet_ntoa(conn_info.local_adr)); for(u8 n = 0; ip_address[n]; n++) if(ip_address[n] == '.') ip_address[n] = ','; int data_s = NONE; // data socket @@ -462,7 +462,7 @@ static void handleclient_ftp(u64 conn_s_ftp_p) { if(is_dev_blind && file_exists(filename)) { - u16 len = sprintf(source, "%s", filename); + u16 len = strcopy(source, filename); sprintf(filename + len, ".~"); if(file_exists(filename)) {filename[len] = *source = NULL;} // overwrite if the temp file exists } @@ -977,17 +977,17 @@ static void handleclient_ftp(u64 conn_s_ftp_p) entry_name); } else - slen = sprintf(buffer, "%s%s%s%s%s%s%s%s%s%s 1 root root %13llu %s %02i %02i:%02i %s\r\n", - (mode & S_IFDIR) ? "d" : "-", - (mode & S_IRUSR) ? "r" : "-", - (mode & S_IWUSR) ? "w" : "-", - (mode & S_IXUSR) ? "x" : "-", - (mode & S_IRGRP) ? "r" : "-", - (mode & S_IWGRP) ? "w" : "-", - (mode & S_IXGRP) ? "x" : "-", - (mode & S_IROTH) ? "r" : "-", - (mode & S_IWOTH) ? "w" : "-", - (mode & S_IXOTH) ? "x" : "-", + slen = sprintf(buffer, "%c%c%c%c%c%c%c%c%c%c 1 root root %13llu %s %02i %02i:%02i %s\r\n", + (mode & S_IFDIR) ? 'd' : '-', + (mode & S_IRUSR) ? 'r' : '-', + (mode & S_IWUSR) ? 'w' : '-', + (mode & S_IXUSR) ? 'x' : '-', + (mode & S_IRGRP) ? 'r' : '-', + (mode & S_IWGRP) ? 'w' : '-', + (mode & S_IXGRP) ? 'x' : '-', + (mode & S_IROTH) ? 'r' : '-', + (mode & S_IWOTH) ? 'w' : '-', + (mode & S_IXOTH) ? 'x' : '-', (unsigned long long)entry.attribute.st_size, smonth[rDate.month - 1], rDate.day, rDate.hour, rDate.minute, entry_name); } diff --git a/include/init/html.h b/include/init/html.h index e1dfe928..e4f52419 100644 --- a/include/init/html.h +++ b/include/init/html.h @@ -348,7 +348,10 @@ static size_t add_radio_button(const char *name, int value, const char *id, cons if(!buffer || !label) return 0; char html[MAX_LINE_LEN]; - sprintf(html, "", name, value, id, checked ? ITEM_CHECKED : "", label, (sufix) ? sufix : "
"); + sprintf(html, "", + name, value, id, + checked ? ITEM_CHECKED : "", + label, (sufix) ? sufix : "
"); return concat(buffer, html); } @@ -365,7 +368,11 @@ static size_t add_check_box(const char *name, bool disabled, const char *label, const char *on_startup = pos + strlen(AUTOBOOT_PATH); // sufix sprintf(autob + n, HTML_INPUT("autop", "%s", "255", "40") "%s", webman_config->autoboot_path, on_startup); } - sprintf(html, "%s", name, disabled ? HTML_DISABLED_CHECKBOX : "", checked ? ITEM_CHECKED : "", clabel, (!sufix) ? "
" : sufix); + sprintf(html, "%s", + name, + disabled ? HTML_DISABLED_CHECKBOX : "", + checked ? ITEM_CHECKED : "", + clabel, (!sufix) ? "
" : sufix); return concat(buffer, html); } diff --git a/include/init/language.h b/include/init/language.h index 00dd0a3d..1c02fa94 100644 --- a/include/init/language.h +++ b/include/init/language.h @@ -328,12 +328,12 @@ static void language(const char *key_name, char *label, const char *default_str) char lang_path[48]; if(lang_roms == LANG_CUSTOM) - snprintf(lang_path, 48, "%s/gamelist.txt", default_str); + snprintf(lang_path, sizeof(lang_path), "%s/gamelist.txt", default_str); else if(lang_roms) { - sprintf(lang_path, "%s/LANG_ROMS.TXT", WM_LANG_PATH); + concat_path(lang_path, WM_LANG_PATH, "LANG_ROMS.TXT"); if(not_exists(lang_path)) - sprintf(lang_path, "%s/LANG_EMUS.TXT", WM_LANG_PATH); + concat_path(lang_path, WM_LANG_PATH, "LANG_EMUS.TXT"); } else { @@ -419,7 +419,7 @@ static void update_language(void) *COVERS_PATH = NULL; // initialize variables with default values - sprintf(STR_SETTINGSUPD, "%s%s", "Settings updated.
", "
Click here to restart your PLAYSTATION®3 system."); + concat2(STR_SETTINGSUPD, "Settings updated.
", "
Click here to restart your PLAYSTATION®3 system."); { language("STR_FILES", STR_FILES, "Files"); diff --git a/include/init/singstar.h b/include/init/singstar.h index 26c02928..842408cf 100644 --- a/include/init/singstar.h +++ b/include/init/singstar.h @@ -30,7 +30,7 @@ static void no_singstar_icon(void) { int fd2; - sprintf(country_path, "%s/%s/c", XIL2_DIR, country_id); + concat_path2(country_path, XIL2_DIR, country_id, "/c"); if(cellFsOpendir(country_path, &fd2) == CELL_FS_SUCCEEDED) { @@ -56,7 +56,7 @@ static void no_singstar_icon(void) } else { - sprintf(country_path, "%s/%s", XIL2_DIR, country_id); + concat_path(country_path, XIL2_DIR, country_id); del(country_path, RECURSIVE_DELETE); // allow restore singstar icon } } diff --git a/include/init/string.h b/include/init/string.h index e455e585..0c21bc82 100644 --- a/include/init/string.h +++ b/include/init/string.h @@ -1,6 +1,24 @@ #define LCASE(a) (a | 0x20) extern char *strcasestr(const char *s1, const char *s2); +extern char *strfmt(const char *fmt, ...); + +#ifdef VIDEO_REC +static char *strnum(const char *str, int num) +{ + return strstr(str, strfmt("%i", num)); +} +#endif + +static int strcopy(char *dest, const char *src) +{ + return sprintf(dest, "%s", src); +} + +static int strncopy(char *dest, int length, const char *src) +{ + return snprintf(dest, length, "%s", src); +} typedef struct { u32 size; @@ -63,6 +81,26 @@ static size_t concat(char *dest, const char *src) return _concat(&fast_concat, src) - dest; } +static size_t concat2(char *dest, const char *src1, const char *src2) +{ + return sprintf(dest, "%s%s", src1, src2); +} + +static void concat3(char *dest, const char *src1, const char *src2, const char *src3) +{ + sprintf(dest, "%s%s%s", src1, src2, src3); +} + +static size_t concat_path(char *dest, const char *src1, const char *src2) +{ + return sprintf(dest, "%s/%s", src1, src2); +} + +static size_t concat_path2(char *dest, const char *src1, const char *src2, const char *src3) +{ + return sprintf(dest, "%s/%s%s", src1, src2, src3); +} + static void memcpy64(void *dst, const void *src, int n) { if(!dst || !src || !n) return; @@ -109,7 +147,7 @@ static char *replace(char *text, const char *rep, const char *with, int count) if(gap >= 0) memcpy(pos, with, len_with); else - sprintf(pos, "%s%s", with, pos + len_with - gap); + concat2(pos, with, pos + len_with - gap); pos = strstr(pos + len_with, rep); } diff --git a/include/init/vsh.h b/include/init/vsh.h index b336b388..2ed22b11 100644 --- a/include/init/vsh.h +++ b/include/init/vsh.h @@ -82,8 +82,8 @@ static int get_game_info(void) game_interface = (game_plugin_interface *)plugin_GetInterface(is_ingame, 1); game_interface->gameInfo(_game_info); - snprintf(_game_TitleID, 10, "%s", _game_info+0x04); - snprintf(_game_Title, 64, "%s", _game_info+0x14); + strncopy(_game_TitleID, 10, _game_info+0x04); + strncopy(_game_Title, 64, _game_info+0x14); } return is_ingame; @@ -136,9 +136,8 @@ static void exec_xmb_command(const char *cmd) static void exec_xmb_command2(const char *cmd, const char *param) { - char explore_command[128]; // info: http://www.psdevwiki.com/ps3/explore_plugin - sprintf(explore_command, cmd, param); - exec_xmb_command(explore_command); + // info: http://www.psdevwiki.com/ps3/explore_plugin + exec_xmb_command(strfmt(cmd, param)); } #ifdef PKG_HANDLER @@ -202,7 +201,7 @@ static bool explore_exec_push(u32 usecs, u8 focus_first) return false; } -static void exec_xmb_item(char *category, char *seg_name, bool execute) +static void exec_xmb_item(const char *category, const char *seg_name, bool execute) { u8 n; @@ -219,11 +218,11 @@ static void exec_xmb_item(char *category, char *seg_name, bool execute) if(explore_interface) { // default category - if(!*category) sprintf(category, "game"); + if(!category) category = "game"; // default segment - if(mount_unk == APP_GAME) sprintf(seg_name, "seg_gamedebug"); else - if(!*seg_name) sprintf(seg_name, webman_config->noBD ? "seg_gamedebug" : "seg_device"); + if(mount_unk == APP_GAME) seg_name = "seg_gamedebug"; else + if(!seg_name) seg_name = webman_config->noBD ? "seg_gamedebug" : "seg_device"; if(!IS(seg_name, "seg_device") || isDir("/dev_bdvd")) { @@ -239,9 +238,9 @@ static void exec_xmb_item(char *category, char *seg_name, bool execute) { if(isDir("/dev_bdvd/PS3_GAME")) {timeout = 40, icon_found = timeout - 5;} else if(file_exists("/dev_bdvd/SYSTEM.CNF")) {timeout = 4, icon_found = 0;} else - if(isDir("/dev_bdvd/BDMV") ) {sprintf(category, "video"); sprintf(seg_name, "seg_bdmav_device");} else - if(isDir("/dev_bdvd/VIDEO_TS")) {sprintf(category, "video"); sprintf(seg_name, "seg_dvdv_device" );} else - if(isDir("/dev_bdvd/AVCHD")) {sprintf(category, "video"); sprintf(seg_name, "seg_avchd_device");} else + if(isDir("/dev_bdvd/BDMV") ) {category = "video", seg_name = "seg_bdmav_device";} else + if(isDir("/dev_bdvd/VIDEO_TS")) {category = "video", seg_name = "seg_dvdv_device" ;} else + if(isDir("/dev_bdvd/AVCHD")) {category = "video", seg_name = "seg_avchd_device";} else return; } else {timeout = 1, icon_found = 1;} @@ -298,8 +297,7 @@ static bool is_app_home_onxmb(void) static void launch_disc(bool exec) { - char category[8], seg_name[16]; *category = *seg_name = NULL; - exec_xmb_item(category, seg_name, exec); + exec_xmb_item(NULL, NULL, exec); } static bool launch_app_home_icon(bool exec) @@ -385,21 +383,11 @@ static void reload_by_logout(void) } } -static int count_items(const char *path) -{ - int fd; u32 count = 0; - if(cellFsOpendir(path, &fd) == CELL_FS_SUCCEEDED) - { - CellFsDirectoryEntry entry; size_t read_e; +static int folder_count(const char *path, s8 max_items); - while(working) - { - if(cellFsGetDirectoryEntries(fd, &entry, sizeof(entry), &read_e) || !read_e) break; - if(entry.entry_name.d_name[0] != '.') ++count; - } - cellFsClosedir(fd); - } - return count; +static bool has_one_user_dir(void) +{ + return folder_count(HDD0_HOME_DIR, 2) <= 1; } #endif @@ -411,7 +399,7 @@ static void reload_xmb(u8 use_app) #ifdef LITE_EDITION if(!cobra_version) #else - if((webman_config->reloadxmb == 2) || (!use_app && count_items(HDD0_HOME_DIR) <= 1)) use_app = true; + if((webman_config->reloadxmb == 2) || (!use_app && has_one_user_dir())) use_app = true; if(!use_app || !cobra_version) { @@ -447,7 +435,7 @@ static void reload_xmb(u8 use_app) if(IS_ON_XMB && USER_LOGGEDIN) { - if((webman_config->reloadxmb == 2) || (!use_app && count_items(HDD0_HOME_DIR) <= 1)) use_app = true; + if((webman_config->reloadxmb == 2) || (!use_app && has_one_user_dir())) use_app = true; if(!use_app) { diff --git a/include/mount/cue_file.h b/include/mount/cue_file.h index ca2275d9..cbcf89b5 100644 --- a/include/mount/cue_file.h +++ b/include/mount/cue_file.h @@ -6,7 +6,7 @@ static int parse_lba(const char *templn, int ret_value) char *time = strrchr(templn, ' '); if(!time) return ret_value; char tcode[10]; // mm:ss:ff - int tcode_len = snprintf(tcode, 8, "%s", time + 1); tcode[8] = '\0'; + int tcode_len = strncopy(tcode, 8, time + 1); tcode[8] = '\0'; if((tcode_len != 8) || tcode[2]!=':' || tcode[5]!=':') return ret_value; unsigned int tmin, tsec, tfrm; diff --git a/include/mount/fix_game.h b/include/mount/fix_game.h index e51dc078..a134fb17 100644 --- a/include/mount/fix_game.h +++ b/include/mount/fix_game.h @@ -146,7 +146,7 @@ static void fix_iso(char *iso_file, u64 maxbytes, bool patch_update) int fd; char title_id[10], update_path[STD_PATH_LEN]; #ifdef COPY_PS3 - sprintf(current_file, "%s", iso_file); + strcopy(current_file, iso_file); #endif show_progress(iso_file, OV_FIX); @@ -277,10 +277,10 @@ static void fix_iso(char *iso_file, u64 maxbytes, bool patch_update) } // fix update folder - sprintf(update_path, "%s/%s/PARAM.SFO", HDD0_GAME_DIR, title_id); + concat_path2(update_path, HDD0_GAME_DIR, title_id, "/PARAM.SFO"); if(getTitleID(update_path, title_id, FIX_SFO) || webman_config->fixgame==FIX_GAME_FORCED) { - sprintf(update_path, "%s%s/USRDIR", HDD0_GAME_DIR, title_id); + concat_path2(update_path, HDD0_GAME_DIR, title_id, "/USRDIR"); fix_game_folder(update_path); } } @@ -311,9 +311,9 @@ static void fix_game(char *game_path, char *title_id, u8 fix_type) if(islike(game_path, "/net") || strstr(game_path, ".ntfs[")) {get_name(filename, get_filename(game_path) + 1, GET_WMTMP); strcat(filename, ".SFO");} else - sprintf(filename, "%s/PARAM.SFO", game_path); + concat2(filename, game_path, "/PARAM.SFO"); - if(not_exists(filename)) sprintf(filename, "%s/PS3_GAME/PARAM.SFO", game_path); + if(not_exists(filename)) concat2(filename, game_path, "/PS3_GAME/PARAM.SFO"); if(not_exists(filename)) {wait_for("/dev_bdvd", 10); sprintf(filename, "/dev_bdvd/PS3_GAME/PARAM.SFO");} char paramsfo[_4KB_]; @@ -323,7 +323,7 @@ static void fix_game(char *game_path, char *title_id, u8 fix_type) if(is_sfo(mem)) { // fix ps3 extra or bgm + remoteplay + ps3 extra - char tmp_path[STD_PATH_LEN]; sprintf(tmp_path, "%s/PS3_EXTRA", game_path); bool has_ps3_extra = isDir(tmp_path); + char tmp_path[STD_PATH_LEN]; concat2(tmp_path, game_path, "/PS3_EXTRA"); bool has_ps3_extra = isDir(tmp_path); if((fix_type == FIX_GAME_FORCED || (has_ps3_extra && fix_type != FIX_GAME_DISABLED)) && fix_sfo_attribute(mem, (u16)bytes_read)) { save_file(filename, paramsfo, bytes_read); @@ -367,7 +367,7 @@ static void fix_game(char *game_path, char *title_id, u8 fix_type) sprintf(filename, "%s %s%s", STR_FIXING, HDD0_GAME_DIR, title_id); show_msg(filename); - sprintf(filename, "%s%s/USRDIR", HDD0_GAME_DIR, title_id); // fix update folder in /dev_hdd0/game + concat_path2(filename, HDD0_GAME_DIR, title_id, "/USRDIR"); // fix update folder in /dev_hdd0/game fix_game_folder(filename); } diff --git a/include/mount/gamedata.h b/include/mount/gamedata.h index 07dabc44..cec9519c 100644 --- a/include/mount/gamedata.h +++ b/include/mount/gamedata.h @@ -5,7 +5,7 @@ static u8 get_default_usb_drive(const char *folder) for(n = 1; n < MAX_DRIVES; n++) { if(n == NET) n = NTFS + 1; - sprintf(usb_path, "%s%s", drives[n], folder); if(isDir(usb_path)) return n; // 1-6 / 13-15 + concat2(usb_path, drives[n], folder); if(isDir(usb_path)) return n; // 1-6 / 13-15 } if(folder) diff --git a/include/mount/mount.h b/include/mount/mount.h index 32dde0b2..d0ce5160 100644 --- a/include/mount/mount.h +++ b/include/mount/mount.h @@ -155,7 +155,7 @@ static void auto_play(char *param, u8 force_autoplay) const char *folder[8] = {"VIDEO", "MOVIES", "MUSIC", "PICTURE", "PHOTOS", "COMICS", "EBOOK", "MAGAZINE"}; for(u8 i = 0; i < 8; i++) { - sprintf(path, "/dev_bdvd/%s", folder[i]); + concat_path(path, "/dev_bdvd", folder[i]); if(isDir(path)) { const char *category = (i < 2) ? "video" : @@ -375,7 +375,7 @@ static bool game_mount(char *buffer, char *html, char *param, char *tempstr, boo } else { - slen = sprintf(_path, "%s", source); + slen = strcopy(_path, source); } // ----------------- @@ -400,7 +400,7 @@ static bool game_mount(char *buffer, char *html, char *param, char *tempstr, boo { if(is_dir) { - sprintf(full_path, "%s/%s/PS3_GAME/PARAM.SFO", _path, d_name); check_ps3_game(full_path); + concat_path2(full_path, _path, d_name, "/PS3_GAME/PARAM.SFO"); check_ps3_game(full_path); get_title_and_id_from_sfo(full_path, title_id, d_name, icon, buf, 0); f1 = id_GAMES; } #ifdef COBRA_ONLY @@ -438,7 +438,7 @@ static bool game_mount(char *buffer, char *html, char *param, char *tempstr, boo { dont_copy_same_size = false; // force copy normalize_path(source, false); - sprintf(target, "%s%s", source, get_filename(cp_path)); + concat2(target, source, get_filename(cp_path)); strcpy(source, cp_path); } else @@ -456,89 +456,89 @@ static bool game_mount(char *buffer, char *html, char *param, char *tempstr, boo #endif // #ifdef SWAP_KERNEL if(strstr(source, "/***PS3***/")) { - sprintf(target, "/dev_hdd0/PS3ISO%s.iso", filename); // /copy.ps3/net0/***PS3***/GAMES/BLES12345 -> /dev_hdd0/PS3ISO/BLES12345.iso + concat_path2(target, "/dev_hdd0/PS3ISO", filename, ".iso"); // /copy.ps3/net0/***PS3***/GAMES/BLES12345 -> /dev_hdd0/PS3ISO/BLES12345.iso } else if(strstr(source, "/***DVD***/")) { - sprintf(target, "/dev_hdd0/DVDISO%s.iso", filename); // /copy.ps3/net0/***DVD***/folder -> /dev_hdd0/DVDISO/folder.iso + concat_path2(target, "/dev_hdd0/DVDISO", filename, ".iso"); // /copy.ps3/net0/***DVD***/folder -> /dev_hdd0/DVDISO/folder.iso } else if(IS(ext, ".pkg")) { if(is_copying_from_hdd) - sprintf(target, "%s/Packages", drives[usb]); + concat2(target, drives[usb], "/Packages"); else - sprintf(target, "/dev_hdd0/packages"); + strcopy(target, "/dev_hdd0/packages"); strcat(target, filename); } else if(_IS(ext, ".bmp") || _IS(ext, ".gif")) { if(is_copying_from_hdd) - sprintf(target, "%s/PICTURE", drives[usb]); + concat2(target, drives[usb], "/PICTURE"); else - sprintf(target, "%s/PICTURE", drives[0]); + concat2(target, drives[0], "/PICTURE"); strcat(target, filename); } else if(_IS(ext, ".jpg") || _IS(ext, ".png")) { if(is_copying_from_hdd) - sprintf(target, "%s/PICTURE", drives[usb]); + concat2(target, drives[usb], "/PICTURE"); else if(strstr(source, "BL") || strstr(param, "BC") || strstr(source, "NP")) - sprintf(target, "/dev_hdd0/GAMES/covers"); + strcopy(target, "/dev_hdd0/GAMES/covers"); else - sprintf(target, "%s/PICTURE", drives[0]); + concat2(target, drives[0], "/PICTURE"); strcat(target, filename); } else if(strcasestr(source, "/covers")) { if(is_copying_from_hdd) - sprintf(target, "%s/COVERS", drives[usb]); + concat2(target, drives[usb], "/COVERS"); else - sprintf(target, "/dev_hdd0/GAMES/covers"); + strcopy(target, "/dev_hdd0/GAMES/covers"); } else if(_IS(ext, ".mp4") || _IS(ext, ".mkv") || _IS(ext, ".avi")) { if(is_copying_from_hdd) - sprintf(target, "%s/VIDEO", drives[usb]); + concat2(target, drives[usb], "/VIDEO"); else - sprintf(target, "/dev_hdd0/VIDEO"); + concat2(target, drives[0], "/VIDEO"); strcat(target, filename); } else if(_IS(ext, ".mp3")) { if(is_copying_from_hdd) - sprintf(target, "%s/MUSIC", drives[usb]); + concat2(target, drives[usb], "/MUSIC"); else - sprintf(target, "%s/MUSIC", drives[0]); + concat2(target, drives[0], "/MUSIC"); strcat(target, filename); } else if(IS(ext, ".p3t")) { if(is_copying_from_hdd) - sprintf(target, "%s/PS3/THEME", drives[usb]); + concat2(target, drives[usb], "/PS3/THEME"); else - sprintf(target, "/dev_hdd0/theme"); + strcopy(target, "/dev_hdd0/theme"); strcat(target, filename); } else if(!extcmp(source, ".edat", 5)) { if(is_copying_from_hdd) - sprintf(target, "%s/exdata", drives[usb]); + concat2(target, drives[usb], "/exdata"); else - sprintf(target, "%s/%s/exdata", HDD0_HOME_DIR, webman_config->uaccount); + concat_path2(target, HDD0_HOME_DIR, webman_config->uaccount, "/exdata"); strcat(target, filename); } else if(IS(ext, ".rco") || strstr(source, "/coldboot")) { enable_dev_blind(NO_MSG); - sprintf(target, "/dev_blind/vsh/resource"); + strcopy(target, "/dev_blind/vsh/resource"); if(IS(ext, ".raf")) strcat(target, "/coldboot.raf"); @@ -548,7 +548,7 @@ static bool game_mount(char *buffer, char *html, char *param, char *tempstr, boo else if(IS(ext, ".qrc")) { enable_dev_blind(NO_MSG); - sprintf(target, "%s/qgl", "/dev_blind/vsh/resource"); + concat2(target, "/dev_blind/vsh/resource", "/qgl"); if(strstr(param, "/lines")) strcat(target, "/lines.qrc"); @@ -558,49 +558,49 @@ static bool game_mount(char *buffer, char *html, char *param, char *tempstr, boo else if(strstr(source, "/exdata")) { if(is_copying_from_hdd) - sprintf(target, "%s/exdata", drives[usb]); + concat2(target, drives[usb], "/exdata"); else - sprintf(target, "%s/%s/exdata", HDD0_HOME_DIR, webman_config->uaccount); + concat_path2(target, HDD0_HOME_DIR, webman_config->uaccount, "/exdata"); } else if(strstr(source, "/PS3/THEME")) - sprintf(target, "/dev_hdd0/theme"); + strcopy(target, "/dev_hdd0/theme"); else if(strcasestr(source, "/savedata/")) { if(is_copying_from_hdd) - sprintf(target, "%s/PS3/SAVEDATA", drives[usb]); + concat2(target, drives[usb], "/PS3/SAVEDATA"); else - sprintf(target, "%s/%s/savedata", HDD0_HOME_DIR, webman_config->uaccount); + concat_path2(target, HDD0_HOME_DIR, webman_config->uaccount, "/savedata"); strcat(target, filename); } else if(strcasestr(source, "/trophy/")) { if(is_copying_from_hdd) - sprintf(target, "%s/PS3/TROPHY", drives[usb]); + concat2(target, drives[usb], "/PS3/TROPHY"); else - sprintf(target, "%s/%s/trophy", HDD0_HOME_DIR, webman_config->uaccount); + concat_path2(target, HDD0_HOME_DIR, webman_config->uaccount, "/trophy"); strcat(target, filename); } else if(strstr(source, "/webftp_server")) { - sprintf(target, "%s/webftp_server.sprx", "/dev_hdd0/plugins"); - if(not_exists(target)) sprintf(target + 31, "_ps3mapi.sprx"); - if(not_exists(target)) sprintf(target + 10, "webftp_server.sprx"); - if(not_exists(target)) sprintf(target + 23, "_ps3mapi.sprx"); + concat_path(target, "/dev_hdd0/plugins", "webftp_server.sprx"); + if(not_exists(target)) strcopy(target + 31, "_ps3mapi.sprx"); + if(not_exists(target)) strcopy(target + 10, "webftp_server.sprx"); + if(not_exists(target)) strcopy(target + 23, "_ps3mapi.sprx"); } else if(strstr(source, "/boot_plugins")) { - sprintf(target, "/dev_hdd0/boot_plugins.txt"); + strcopy(target, "/dev_hdd0/boot_plugins.txt"); if(cobra_version == 0) - sprintf(target + 22, "_nocobra.txt"); + strcopy(target + 22, "_nocobra.txt"); } else if(is_copying_from_hdd) - sprintf(target, "%s%s", drives[usb], source + 9); + concat2(target, drives[usb], source + 9); else if(islike(source, "/dev_usb")) - sprintf(target, "%s%s", drives[0], source + 11); + concat2(target, drives[0], source + 11); else if(islike(source, "/net")) - sprintf(target, "%s%s", drives[0], source + 5); + concat2(target, drives[0], source + 5); else { if(islike(source, "/dev_bdvd")) @@ -613,7 +613,7 @@ static bool game_mount(char *buffer, char *html, char *param, char *tempstr, boo } while (isDir(target)); char title[128]; - sprintf(title, "/dev_bdvd/PS3_GAME/PARAM.SFO"); check_ps3_game(title); + strcopy(title, "/dev_bdvd/PS3_GAME/PARAM.SFO"); check_ps3_game(title); if(file_exists(title)) { char title_id[TITLEID_LEN]; @@ -664,7 +664,7 @@ static bool game_mount(char *buffer, char *html, char *param, char *tempstr, boo // show target path use_open_path = true; add_breadcrumb_trail(buffer, target); *tempstr = NULL; - if(strstr(target, "/webftp_server")) {sprintf(tempstr, "


%s", STR_SETTINGSUPD);} else + if(strstr(target, "/webftp_server")) {concat2(tempstr, "
", STR_SETTINGSUPD);} else if(cp_mode) {dont_copy_same_size = true; char *p = get_filename(_path); *p = NULL; sprintf(tempstr, HTML_REDIRECT_TO_URL, _path, HTML_REDIRECT_WAIT);} if(g_sysmem) {sys_memory_free(g_sysmem); g_sysmem = NULL;} @@ -823,7 +823,7 @@ static bool game_mount(char *buffer, char *html, char *param, char *tempstr, boo if(is_iso || strstr(entry_name, "[PS2")) { - if(pcount == 0) strcat(buffer, "

"); + if(pcount == 0) strcat(buffer, "

"); urlenc(enc_dir_name, entry_name); tlen += sprintf(html, "%s
", target, enc_dir_name, entry_name); @@ -957,7 +957,7 @@ void map_app_home(const char *path) { sys_map_path("/app_home", path); - sprintf(mpath, "%s/PS3_GM01", path); + concat2(mpath, path, "/PS3_GM01"); gm = isDir(mpath) ? 01 : 00; // reset gm to 00 if the game is not a multi-game disc } else @@ -1097,7 +1097,7 @@ static void do_umount(bool clean) if(*map_title_id) { char gamei_mapping[32]; - sprintf(gamei_mapping, "%s%s", HDD0_GAME_DIR, map_title_id); + concat2(gamei_mapping, HDD0_GAME_DIR, map_title_id); unmap_path(gamei_mapping); unmap_path(PKGLAUNCH_DIR); *map_title_id = NULL; @@ -1160,7 +1160,7 @@ static void cache_file_to_hdd(char *source, char *target, const char *basepath, { if(*source == '/') { - sprintf(target, "/dev_hdd0%s", basepath); + concat2(target, "/dev_hdd0", basepath); cellFsMkdir(target, DMODE); strcat(target, get_filename(source)); // add file name @@ -1342,11 +1342,11 @@ static void mount_on_insert_usb(bool on_xmb, char *msg) if(automount != f0) { char *game_path = msg; - sprintf(game_path, "%s/AUTOMOUNT.ISO", drives[f0]); + concat2(game_path, drives[f0], "/AUTOMOUNT.ISO"); if(file_exists(game_path)) {mount_game(game_path, MOUNT_SILENT); automount = f0; break;} else { - sprintf(game_path, "%s/PS3_GAME/PARAM.SFO", drives[f0]); check_ps3_game(game_path); + concat2(game_path, drives[f0], "/PS3_GAME/PARAM.SFO"); check_ps3_game(game_path); if(file_exists(game_path)) {mount_game(game_path, MOUNT_SILENT); automount = f0; break;} } } @@ -1713,7 +1713,7 @@ static void mount_thread(u64 action) getTitleID(filename, title_id, GET_TITLE_ID_ONLY); // check for PARAM.SFO in hdd0/game folder - sprintf(filename, "%s%s%s", HDD0_GAME_DIR, title_id, "/PARAM.SFO"); + concat3(filename, HDD0_GAME_DIR, title_id, "/PARAM.SFO"); if(not_exists(filename)) { @@ -1724,7 +1724,7 @@ static void mount_thread(u64 action) if(strcasestr(_path0, ".iso") || strstr(_path0, ".ntfs[PS3ISO]")) { strcpy(map_title_id, title_id); - sprintf(filename, "%s%s", HDD0_GAME_DIR, map_title_id); + concat2(filename, HDD0_GAME_DIR, map_title_id); sys_map_path(filename, "/dev_bdvd/PS3_GAME"); } } @@ -1808,10 +1808,10 @@ static void mount_thread(u64 action) { set_app_home(_path0); - sprintf(_path, "%s/PARAM.SFO", "/dev_bdvd"); + concat2(_path, "/dev_bdvd", "/PARAM.SFO"); getTitleID(_path, map_title_id, GET_TITLE_ID_ONLY); - sprintf(_path, "%s%s", HDD0_GAME_DIR, map_title_id); + concat2(_path, HDD0_GAME_DIR, map_title_id); sys_map_path(_path, _path0); sys_ppu_thread_sleep(1); diff --git a/include/mount/mount_cobra.h b/include/mount/mount_cobra.h index 77f0b903..e1d0d2ac 100644 --- a/include/mount/mount_cobra.h +++ b/include/mount/mount_cobra.h @@ -78,7 +78,7 @@ if(!cobra_version) {ret = false; goto finish;} u8 iso_parts = 1; - size_t path_len = sprintf(full_path, "%s", _path); + size_t path_len = strcopy(full_path, _path); CD_SECTOR_SIZE_2352 = 2352; @@ -410,7 +410,7 @@ if(!cobra_version) {ret = false; goto finish;} #else char filename[STD_PATH_LEN + 20]; - sprintf(filename, "%s/PS3_GAME/PARAM.SFO", _path); + concat2(filename, _path, "/PS3_GAME/PARAM.SFO"); getTitleID(filename, title_id, GET_TITLE_ID_ONLY); #endif // ---- diff --git a/include/mount/mount_lastgames.h b/include/mount/mount_lastgames.h index cf756f93..06840529 100644 --- a/include/mount/mount_lastgames.h +++ b/include/mount/mount_lastgames.h @@ -44,12 +44,12 @@ if(lastgames.last >= MAX_LAST_GAMES) { lastgames.last = 0; - snprintf(lastgames.game[lastgames.last].path, STD_PATH_LEN, "%s", _path); + strncopy(lastgames.game[lastgames.last].path, STD_PATH_LEN, _path); } else { // multi-CD - char multi[STD_PATH_LEN]; snprintf(multi, STD_PATH_LEN, "%s", _path); + char multi[STD_PATH_LEN]; strncopy(multi, STD_PATH_LEN, _path); char *mcd = is_multi_cd(multi); u8 n; @@ -62,7 +62,7 @@ { lastgames.last++; if(lastgames.last >= MAX_LAST_GAMES) lastgames.last = 0; - snprintf(lastgames.game[lastgames.last].path, STD_PATH_LEN, "%s", _path); + strncopy(lastgames.game[lastgames.last].path, STD_PATH_LEN, _path); // multi-CD if(mcd) @@ -81,7 +81,7 @@ n++; if(n >= MAX_LAST_GAMES) n = 0; - snprintf(lastgames.game[n].path, STD_PATH_LEN, "%s", multi); multiCD = true; + strncopy(lastgames.game[n].path, STD_PATH_LEN, multi); multiCD = true; } } } diff --git a/include/mount/mount_misc.h b/include/mount/mount_misc.h index b2a4274c..9c655dd8 100644 --- a/include/mount/mount_misc.h +++ b/include/mount/mount_misc.h @@ -30,7 +30,7 @@ get_value(map_title_id, pos, TITLE_ID_LEN); } - sprintf(_path, "%s%s", HDD0_GAME_DIR, map_title_id); + concat2(_path, HDD0_GAME_DIR, map_title_id); sys_map_path(_path, _path0); ret = is_app_dir("/dev_hdd0/game", map_title_id); @@ -93,10 +93,10 @@ if(islike(_path0, HDD0_GAME_DIR)) { - sprintf(_path, "%s%s", HDD0_GAME_DIR, _path0 + 15); // use /dev_hdd0/game/ + concat2(_path, HDD0_GAME_DIR, _path0 + 15); // use /dev_hdd0/game/ if(not_exists(_path)) { - sprintf(_path, "%s%s", _HDD0_GAME_DIR, _path0 + 15); // use /dev_hdd0//game/ if GAMEI is enabled + concat2(_path, _HDD0_GAME_DIR, _path0 + 15); // use /dev_hdd0//game/ if GAMEI is enabled } } ret = isDir(_path); diff --git a/include/mount/mount_net.h b/include/mount/mount_net.h index eb7c7f39..bb861690 100644 --- a/include/mount/mount_net.h +++ b/include/mount/mount_net.h @@ -27,7 +27,7 @@ if(BETWEEN('0', netid, '4')) } } - size_t len = sprintf(netiso_args.path, "%s", netpath); + size_t len = strcopy(netiso_args.path, netpath); const char *ext = strrchr(netpath, '.'); bool is_iso = ext && strcasestr(ISO_EXTENSIONS, ext); @@ -133,16 +133,16 @@ if(BETWEEN('0', netid, '4')) else if((islike(netpath, "/GAMES") || islike(netpath, "/GAMEZ") || islike(netpath, "/PS3ISO")) && strchr(netpath + 5, '/')) { mount_unk = netiso_args.emu_mode = EMU_PS3; - if(!is_iso) sprintf(netiso_args.path, "/***PS3***%s", netpath); + if(!is_iso) concat2(netiso_args.path, "/***PS3***", netpath); } else if(islike(netpath, "/ROMS")) { //netiso_args.emu_mode = EMU_BD; mount_unk = EMU_ROMS; - sprintf(netiso_args.path, "/***DVD***%s", "/ROMS"); + concat2(netiso_args.path, "/***DVD***", "/ROMS"); - sprintf(full_path, "/dev_bdvd/%s", netpath + 6); + concat2(full_path, "/dev_bdvd/", netpath + 6); save_file(PKGLAUNCH_DIR "/USRDIR/launch.txt", full_path, SAVE_ALL); copy_rom_media(full_path); } @@ -214,7 +214,7 @@ if(BETWEEN('0', netid, '4')) pspiso = strchr(pspiso + 1, '/'); if(pspiso) { - sprintf(full_path, "%s%s", "/dev_bdvd", pspiso); + concat2(full_path, "/dev_bdvd", pspiso); strcpy(_path, full_path); sys_ppu_thread_sleep(1); @@ -246,12 +246,12 @@ if(BETWEEN('0', netid, '4')) wait_for("/dev_bdvd", 15); set_app_home("/dev_bdvd"); // sys_map_path(APP_HOME_DIR, "/dev_bdvd"); - sprintf(full_path, "%s/PARAM.SFO", "/dev_bdvd"); + concat2(full_path, "/dev_bdvd", "/PARAM.SFO"); getTitleID(full_path, map_title_id, GET_TITLE_ID_ONLY); if(*map_title_id) { - sprintf(full_path, "%s/%s", "/dev_hdd0/game", map_title_id); + concat2(full_path, HDD0_GAME_DIR, map_title_id); sys_map_path(full_path, "/dev_bdvd"); } diff --git a/include/mount/mount_noncobra.h b/include/mount/mount_noncobra.h index a2d568b1..f148bed8 100644 --- a/include/mount/mount_noncobra.h +++ b/include/mount/mount_noncobra.h @@ -119,7 +119,7 @@ { char filename[STD_PATH_LEN + 20]; - sprintf(filename, "%s/PS3_GAME/PARAM.SFO", _path); + concat2(filename, _path, "/PS3_GAME/PARAM.SFO"); getTitleID(filename, title_id, GET_TITLE_ID_ONLY); } #else diff --git a/include/mount/netserver.h b/include/mount/netserver.h index dea1568d..a9a5a384 100644 --- a/include/mount/netserver.h +++ b/include/mount/netserver.h @@ -51,7 +51,7 @@ static void translate_path(char *path, u16 fp_len) { if(i == NET) i = NTFS + 1; // skip range from /net0 to /ext - sprintf(path, "%s%s", drives[i], tmppath); + concat2(path, drives[i], tmppath); if(file_exists(path)) break; } @@ -513,7 +513,7 @@ static int process_read_dir_cmd(u8 index, netiso_read_dir_entry_cmd *cmd) if(i == NET) i = NTFS + 1; // skip range from /net0 to /ext - dirpath_len = sprintf(dirpath, "%s%s", drives[i], clients[index].dirpath); + dirpath_len = concat2(dirpath, drives[i], clients[index].dirpath); if(not_exists(dirpath)) continue; @@ -554,7 +554,7 @@ static int process_read_dir_cmd(u8 index, netiso_read_dir_entry_cmd *cmd) dir_entries[count].is_directory = 0; } - snprintf(dir_entries[count].name, 510, "%s", entry.d_name); + strncopy(dir_entries[count].name, 510, entry.d_name); dir_entries[count].mtime = (s64)(st.st_mtime); count++; diff --git a/include/mount/param_sfo.h b/include/mount/param_sfo.h index ab00dbb7..398e3840 100644 --- a/include/mount/param_sfo.h +++ b/include/mount/param_sfo.h @@ -331,7 +331,7 @@ static void get_local_app_ver(char *app_ver, const char *title_id, char *param_s { if(*title_id) { - sprintf(param_sfo, "%s/%s/PARAM.SFO", HDD0_GAME_DIR, title_id); + concat_path2(param_sfo, HDD0_GAME_DIR, title_id, "/PARAM.SFO"); if(not_exists(param_sfo)) {set_param_sfo(param_sfo); return;} diff --git a/include/mount/patch_gameboot.h b/include/mount/patch_gameboot.h index 77483cdc..61d449eb 100644 --- a/include/mount/patch_gameboot.h +++ b/include/mount/patch_gameboot.h @@ -83,10 +83,10 @@ static void patch_gameboot(u8 boot_type) sys_map_path(GAMEBOOT_MULTI_AC3, snd); sys_map_path(GAMEBOOT_STEREO_AC3, snd); - const char *media[6] = {"PIC0.PNG", "PIC1.PNG", "PIC2.PNG", "SND0.AT3", "ICON1.PAM", "ICON0.PNG"}; + const char *media[6] = {"/PIC0.PNG", "/PIC1.PNG", "/PIC2.PNG", "/SND0.AT3", "/ICON1.PAM", "/ICON0.PNG"}; for(u8 i = 0; i < 6; i++) { - sprintf(path, "%s/PS3_GAME/%s", PKGLAUNCH_DIR, media[i]); + concat_path2(path, PKGLAUNCH_DIR, "/PS3_GAME", media[i]); if(not_exists(path)) { char src_path[40]; diff --git a/include/mount/ps2_classic.h b/include/mount/ps2_classic.h index 85e8dc15..8e7808de 100644 --- a/include/mount/ps2_classic.h +++ b/include/mount/ps2_classic.h @@ -35,20 +35,20 @@ static void enable_ps2netemu_cobra(int emu) static void copy_ps2icon(char *imgfile, const char *_path) { char pic[64]; sprintf(pic, PS2_CLASSIC_ISO_ICON); - sprintf(imgfile, "%s.bak", PS2_CLASSIC_ISO_ICON); + concat2(imgfile, PS2_CLASSIC_ISO_ICON, ".bak"); if(not_exists(imgfile)) force_copy(pic, imgfile); - int len = sprintf(imgfile, "%s.png", _path); len -= 12; - if(not_exists(imgfile)) sprintf(imgfile, "%s.PNG", _path); - if(not_exists(imgfile) && (len > 0)) sprintf(imgfile + len, ".png"); // remove .BIN.ENC - if(not_exists(imgfile) && (len > 0)) sprintf(imgfile + len, ".PNG"); + int len = concat2(imgfile, _path, ".png"); len -= 12; + if(not_exists(imgfile)) concat2(imgfile, _path, ".PNG"); + if(not_exists(imgfile) && (len > 0)) strcopy(imgfile + len, ".png"); // remove .BIN.ENC + if(not_exists(imgfile) && (len > 0)) strcopy(imgfile + len, ".PNG"); if(file_exists(imgfile)) cellFsUnlink(pic); else - sprintf(imgfile, "%s.bak", PS2_CLASSIC_ISO_ICON); + concat2(imgfile, PS2_CLASSIC_ISO_ICON, ".bak"); force_copy(imgfile, pic); @@ -151,7 +151,7 @@ static bool copy_ps2config_iso(char *entry_name, char *_path) ) { char temp[STD_PATH_LEN]; - sprintf(temp, "%s/%s.CONFIG", PS2CONFIG_PATH, tempID); + concat_path2(temp, PS2CONFIG_PATH, tempID, ".CONFIG"); if(file_exists(temp)) force_copy(temp, _path); else @@ -214,7 +214,7 @@ static void copy_ps2savedata(char *vme, const char *_path) else sprintf(savedata_vme, "%s/SAVEDATA/SCEVMC%i.VME", PS2_CLASSIC_PLACEHOLDER, i); - sprintf(savedata_bak, "%s.bak", savedata_vme); + concat2(savedata_bak, savedata_vme, ".bak"); if(file_exists(vme)) { cellFsRename(savedata_vme, savedata_bak); // backup default vme @@ -226,7 +226,7 @@ static void copy_ps2savedata(char *vme, const char *_path) cellFsRename(savedata_bak, savedata_vme); // restore backup vme } - len = sprintf(vme, "%s", savedata_vme); vme[len - 5] = '1' - i; + len = strcopy(vme, savedata_vme); vme[len - 5] = '1' - i; if(not_exists(vme)) force_copy(savedata_vme, vme); diff --git a/include/notify/vsh_notify.h b/include/notify/vsh_notify.h index 81435967..e822283d 100644 --- a/include/notify/vsh_notify.h +++ b/include/notify/vsh_notify.h @@ -39,7 +39,7 @@ static void show_progress(const char *path, u8 oper) else if(oper == OV_FIND) snprintf(data, sizeof(data), "\n%s:\n%s", "Searching", path); else // if(oper == OV_SHOW) - snprintf(data, sizeof(data), "%s", path); + strncopy(data, sizeof(data), path); // fix degree character if(overlay_info) @@ -176,12 +176,12 @@ static s32 show_msg_with_icon(u8 icon_id, const char *msg) "tex_go_game", //50 }; - if(icon_id >= MAX_RCO_IMAGES) icon_id = 0; + char rco[64], texture[64]; const char *plugin = "explore_plugin"; - const char *tex = rco_images[icon_id]; + const char *tex = texture; + if(icon_id >= MAX_RCO_IMAGES) icon_id = 0; // custom textures - char rco[64], texture[64]; char *pos = strstr(msg, "&icon="); if(pos) { @@ -193,7 +193,7 @@ static s32 show_msg_with_icon(u8 icon_id, const char *msg) } else if(get_param("&icon=", texture, pos, 63)) { - tex = texture, icon_id = MAX_RCO_IMAGES; + icon_id = MAX_RCO_IMAGES; // example: /popup.ps3?message&icon=item_tex_cam_facebook&rco=explore_plugin if(get_param("&rco=", rco, pos, 63)) @@ -205,6 +205,8 @@ static s32 show_msg_with_icon(u8 icon_id, const char *msg) } *pos = NULL; } + else + tex = rco_images[icon_id]; if(icon_id < 18) plugin = "system_plugin"; @@ -249,8 +251,7 @@ static void show_msg(const char *text) // vshtask_notify = getNIDfunc("vshtask", 0xA02D46E7, 0); //if(!vshtask_notify) return; - char msg[240]; - snprintf(msg, sizeof(msg), "%s", text); + char msg[240]; strncopy(msg, sizeof(msg), text); char *snd = strstr(msg, "&snd="); if(snd) diff --git a/include/poll/combos.h b/include/poll/combos.h index 8edae4d6..bff4c01f 100644 --- a/include/poll/combos.h +++ b/include/poll/combos.h @@ -399,7 +399,7 @@ show_popup: if(is_custom_popup) { - snprintf(msg, 200, "%s", custom_popup_msg); + strncopy(msg, 200, custom_popup_msg); #ifdef COBRA_NON_LITE parse_tags(msg); #endif @@ -872,7 +872,7 @@ get_game_version(path, title, title_id, app_ver); get_last_game(path); if(not_exists(path)) - sprintf(path, "%s%s", HDD0_GAME_DIR, title_id); + concat2(path, HDD0_GAME_DIR, title_id); sprintf(msg, "ID: %s - v%s\n%s\n\n%s", title_id, app_ver, title, path); show_msg(msg); diff --git a/include/ps3mapi/debug_mem.h b/include/ps3mapi/debug_mem.h index 6f4236d5..c3796157 100644 --- a/include/ps3mapi/debug_mem.h +++ b/include/ps3mapi/debug_mem.h @@ -256,7 +256,7 @@ static void ps3mapi_find_peek_poke_hexview(char *buffer, char *templn, char *par flen = Hex2Bin(pos, templn); else { - flen = sprintf(templn, "%s", pos); + flen = strcopy(templn, pos); // convert pipes to line breaks for(pos = templn; *pos; ++pos) if(*pos == '|') *pos = '\n'; } @@ -316,7 +316,7 @@ static void ps3mapi_find_peek_poke_hexview(char *buffer, char *templn, char *par if(isHEX(v + 1)) flen = Hex2Bin(v + 1, sfind); else - flen = sprintf(sfind, "%s", v + 1); + flen = strcopy(sfind, v + 1); u64 (*peek_mem)(u64) = lv1 ? peek_lv1 : peekq; diff --git a/include/ps3mapi/ps3mapi.h b/include/ps3mapi/ps3mapi.h index 25cbd915..228f7924 100644 --- a/include/ps3mapi/ps3mapi.h +++ b/include/ps3mapi/ps3mapi.h @@ -263,7 +263,7 @@ static void start_vsh_gui(bool vsh_menu) unload_vsh_gui(); char plugin_path[40]; - sprintf(plugin_path, "%s/%s.sprx", WM_RES_PATH, vsh_menu ? "wm_vsh_menu" : "slaunch"); + concat_path2(plugin_path, WM_RES_PATH, vsh_menu ? "wm_vsh_menu" : "slaunch", ".sprx"); load_vsh_gui(plugin_path); } #endif @@ -831,7 +831,7 @@ static void ps3mapi_getmem(char *buffer, char *html, const char *param) { find = strstr(param, "find=") + 5; char sfind[0x60], *mask = addr_tmp; - u8 len = snprintf(sfind, sizeof(sfind), "%s", addr_tmp); + u8 len = strncopy(sfind, sizeof(sfind), addr_tmp); // search hex: 0xAABBCC112233 if(isHEX(addr_tmp)) @@ -1074,7 +1074,7 @@ static void ps3mapi_setmem(char *buffer, char *html, const char *param) if(isHEX(val_tmp)) length = Hex2Bin(val_tmp, value); else - length = sprintf(value, "%s", val_tmp); + length = strcopy(value, val_tmp); } } } @@ -1311,7 +1311,7 @@ static void add_plugins_list(char *buffer, char *html, u8 is_vsh) { if(!extcmp(entry_name, ext, ext_len)) { - sprintf(html + plen, "%s", entry_name); concat(buffer, html); if(++cnt > 450) break; + strcopy(html + plen, entry_name); concat(buffer, html); if(++cnt > 450) break; } } cellFsClosedir(fd); @@ -1339,10 +1339,10 @@ static void ps3mapi_vshplugin(char *buffer, char *html, const char *param) sprintf(tmp_filename, "/dev_hdd0/boot_plugins.txt"); if(dex_mode) sprintf(tmp_filename + 22, "_dex.txt"); switch (boot_mode) { - case 1: sprintf(tmp_filename + 10, "mamba_plugins.txt"); break; - case 2: sprintf(tmp_filename + 10, "prx_plugins.txt"); break; - case 3: sprintf(tmp_filename + 10, "game/PRXLOADER/USRDIR/plugins.txt"); break; - case 4: sprintf(tmp_filename + 22, "_nocobra.txt"); if(dex_mode) sprintf(tmp_filename + 30, "_dex.txt"); break; + case 1: strcopy(tmp_filename + 10, "mamba_plugins.txt"); break; + case 2: strcopy(tmp_filename + 10, "prx_plugins.txt"); break; + case 3: strcopy(tmp_filename + 10, "game/PRXLOADER/USRDIR/plugins.txt"); break; + case 4: strcopy(tmp_filename + 22, "_nocobra.txt"); if(dex_mode) sprintf(tmp_filename + 30, "_dex.txt"); break; } sprintf(html, "

%s

", tmp_filename, tmp_filename); concat(buffer, html); @@ -1435,17 +1435,17 @@ static void ps3mapi_vshplugin(char *buffer, char *html, const char *param) } sprintf(html, "

%s > " HTML_BUTTON_FMT - HTML_BUTTON_FMT - HTML_BUTTON_FMT - HTML_BUTTON_FMT - HTML_BUTTON_FMT "", STR_SAVE, - HTML_BUTTON, "boot_plugins.txt", HTML_ONCLICK, "/vshplugin.ps3mapi?s=0", + HTML_BUTTON_FMT + HTML_BUTTON_FMT + HTML_BUTTON_FMT + HTML_BUTTON_FMT "", STR_SAVE, + HTML_BUTTON, "boot_plugins.txt", HTML_ONCLICK, "/vshplugin.ps3mapi?s=0", HTML_BUTTON, dex_mode ? "boot_plugins_nocobra_dex.txt" : - "boot_plugins_nocobra.txt", HTML_ONCLICK, "/vshplugin.ps3mapi?s=4", - HTML_BUTTON, "mamba_plugins.txt", HTML_ONCLICK, "/vshplugin.ps3mapi?s=1", - HTML_BUTTON, "prx_plugins.txt", HTML_ONCLICK, "/vshplugin.ps3mapi?s=2", - HTML_BUTTON, "plugins.txt", HTML_ONCLICK, "/vshplugin.ps3mapi?s=3"); concat(buffer, html); + "boot_plugins_nocobra.txt", HTML_ONCLICK, "/vshplugin.ps3mapi?s=4", + HTML_BUTTON, "mamba_plugins.txt", HTML_ONCLICK, "/vshplugin.ps3mapi?s=1", + HTML_BUTTON, "prx_plugins.txt", HTML_ONCLICK, "/vshplugin.ps3mapi?s=2", + HTML_BUTTON, "plugins.txt", HTML_ONCLICK, "/vshplugin.ps3mapi?s=3"); concat(buffer, html); add_plugins_list(buffer, html, 0); @@ -1470,7 +1470,7 @@ static void ps3mapi_kernelplugin(char *buffer, char *html, const char *param) if(pos) { u8 boot_mode = get_valuen(pos, "?s=", 0, 4); - sprintf(tmp_name, "/dev_hdd0/boot_plugins_kernel.txt"); + strcopy(tmp_name, "/dev_hdd0/boot_plugins_kernel.txt"); if(boot_mode) { sprintf(tmp_name + 29, dex_mode ? "_nocobra_dex.txt" : "_nocobra.txt"); diff --git a/include/ps3mapi/ps3mapi_server.h b/include/ps3mapi/ps3mapi_server.h index 06844210..57705631 100644 --- a/include/ps3mapi/ps3mapi_server.h +++ b/include/ps3mapi/ps3mapi_server.h @@ -108,7 +108,7 @@ static void handleclient_ps3mapi(u64 conn_s_ps3mapi_p) ssend(conn_s_ps3mapi, PS3MAPI_OK_220); - u8 ip_len = sprintf(ip_address, "%s", inet_ntoa(conn_info.local_adr)); + u8 ip_len = strcopy(ip_address, inet_ntoa(conn_info.local_adr)); for(u8 n = 0; n < ip_len; n++) if(ip_address[n] == '.') ip_address[n] = ','; ssend(conn_s_ps3mapi, PS3MAPI_OK_230); @@ -720,23 +720,19 @@ static void handleclient_ps3mapi(u64 conn_s_ps3mapi_p) u32 buf_len = sprintf(buffer, "200 "); {system_call_5(SC_COBRA_SYSCALL8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_GET_PROC_MODULE_SEGMENTS, (u64)pid, (u64)prx_id, (u64)(u32)&moduleInfo); } - buf_len += sprintf(buffer + buf_len, "%s|", moduleInfo.name); - buf_len += sprintf(buffer + buf_len, "%s|", moduleInfo.filename); - buf_len += sprintf(buffer + buf_len, "%i|", moduleInfo.filename_size); - buf_len += sprintf(buffer + buf_len, "%i|", moduleInfo.modattribute); - buf_len += sprintf(buffer + buf_len, "%i|", moduleInfo.start_entry); - buf_len += sprintf(buffer + buf_len, "%i|", moduleInfo.stop_entry); - - buf_len += sprintf(buffer + buf_len, "seg0|%016llX|%016llX|%016llX|%016llX|%016llX", + buf_len += sprintf(buffer + buf_len, "%s|%s|%i|%i|%i|%i|", + moduleInfo.name, moduleInfo.filename, moduleInfo.filename_size, + moduleInfo.modattribute, moduleInfo.start_entry, moduleInfo.stop_entry); + buf_len += sprintf(buffer + buf_len, "seg%c|%016llX|%016llX|%016llX|%016llX|%016llX", '0', moduleInfo.segments[0].base, moduleInfo.segments[0].filesz, moduleInfo.segments[0].memsz, moduleInfo.segments[0].index, moduleInfo.segments[0].type); - buf_len += sprintf(buffer + buf_len, "seg1|%016llX|%016llX|%016llX|%016llX|%016llX", + buf_len += sprintf(buffer + buf_len, "seg%c|%016llX|%016llX|%016llX|%016llX|%016llX", '1', moduleInfo.segments[1].base, moduleInfo.segments[1].filesz, moduleInfo.segments[0].memsz, moduleInfo.segments[1].index, moduleInfo.segments[1].type); - buf_len += sprintf(buffer + buf_len, "seg2|%016llX|%016llX|%016llX|%016llX|%016llX", + buf_len += sprintf(buffer + buf_len, "seg%c|%016llX|%016llX|%016llX|%016llX|%016llX", '2', moduleInfo.segments[2].base, moduleInfo.segments[2].filesz, moduleInfo.segments[0].memsz, moduleInfo.segments[2].index, moduleInfo.segments[2].type); - buf_len += sprintf(buffer + buf_len, "seg3|%016llX|%016llX|%016llX|%016llX|%016llX", + buf_len += sprintf(buffer + buf_len, "seg%c|%016llX|%016llX|%016llX|%016llX|%016llX", '3', moduleInfo.segments[3].base, moduleInfo.segments[3].filesz, moduleInfo.segments[0].memsz, moduleInfo.segments[3].index, moduleInfo.segments[3].type); diff --git a/include/scan/games_covers.h b/include/scan/games_covers.h index 1a9271c3..2429871c 100644 --- a/include/scan/games_covers.h +++ b/include/scan/games_covers.h @@ -74,12 +74,12 @@ static void check_cover_folders(char *folder_path) #endif for(u8 p = 0; p < 3; p++) { - sprintf(folder_path, "%s/covers_retro/psx", cpath[p]); + concat2(folder_path, cpath[p], "/covers_retro/psx"); covers_retro_exist[p] = isDir(folder_path) && !is_empty_dir(folder_path); // MM_ROOT_STD, MM_ROOT_STL, MM_ROOT_SSTL } for(u8 p = 0; p < 6; p++) { - sprintf(folder_path, "%s/covers", cpath[p]); + concat2(folder_path, cpath[p], "/covers"); covers_exist[p + 1] = isDir(folder_path) && !is_empty_dir(folder_path); // MM_ROOT_STD, MM_ROOT_STL, MM_ROOT_SSTL, MANAGUNZ, "/dev_hdd0/GAMES", "/dev_hdd0/GAMEZ" } covers_exist[6] = !is_empty_dir(WMTMP_COVERS); @@ -160,7 +160,7 @@ static size_t get_name(char *name, const char *filename, u8 cache) if(cache == NO_PATH) cache = 0; if(cache == WM_COVERS) - flen = sprintf(name, "%s/%s", WMTMP_COVERS, filename + pos); + flen = concat_path(name, WMTMP_COVERS, filename + pos); else if(cache) { #ifdef USE_NTFS @@ -176,7 +176,7 @@ static size_t get_name(char *name, const char *filename, u8 cache) } else #endif - flen = sprintf(name, "%s/%s", WMTMP, filename + pos); + flen = concat_path(name, WMTMP, filename + pos); } else { @@ -188,7 +188,7 @@ static size_t get_name(char *name, const char *filename, u8 cache) if(islike(prefix, paths[id_PS2ISO])) pos += 9; } - flen = sprintf(name, "%s", filename + pos); + flen = strcopy(name, filename + pos); } flen = remove_ext(name); @@ -205,9 +205,9 @@ static size_t get_name(char *name, const char *filename, u8 cache) if(cache || (flen <= 12)) return (size_t) flen; // remove title id from file name - if(name[4] == '_' && name[8] == '.' && (*name == 'B' || *name == 'N' || *name == 'S' || *name == 'U') && ISDIGIT(name[9]) && ISDIGIT(name[10])) {flen = sprintf(name, "%s", &name[12]);}// SLES_000.00-Name - if(name[9] == '-' && name[10]== '[') {flen = sprintf(name, "%s", name + 11) - 1; name[flen] = '\0';} // BLES00000-[Name] - if(name[10]== '-' && name[11]== '[') {flen = sprintf(name, "%s", name + 12) - 1; name[flen] = '\0';} // BLES-00000-[Name] + if(name[4] == '_' && name[8] == '.' && (*name == 'B' || *name == 'N' || *name == 'S' || *name == 'U') && ISDIGIT(name[9]) && ISDIGIT(name[10])) {flen = strcopy(name, &name[12]);}// SLES_000.00-Name + if(name[9] == '-' && name[10]== '[') {flen = strcopy(name, name + 11) - 1; name[flen] = '\0';} // BLES00000-[Name] + if(name[10]== '-' && name[11]== '[') {flen = strcopy(name, name + 12) - 1; name[flen] = '\0';} // BLES-00000-[Name] if(!webman_config->tid) // Name [BLES-00000] { @@ -233,7 +233,7 @@ static bool get_cover_by_titleid(char *icon, const char *title_id) // Search covers in custom path if(covers_exist[0] && ((webman_config->nocov == SHOW_MMCOVERS) && (*COVERS_PATH == '/'))) { - flen = sprintf(icon, "%s/%s", COVERS_PATH, title_id); + flen = concat_path(icon, COVERS_PATH, title_id); if(get_image_file2(icon, flen)) return true; } #endif @@ -265,14 +265,14 @@ static bool get_cover_by_titleid(char *icon, const char *title_id) // Search covers in WMTMP_COVERS if(covers_exist[6]) { - flen = sprintf(icon, "%s/%s", WMTMP_COVERS, title_id); + flen = concat_path(icon, WMTMP_COVERS, title_id); if(get_image_file2(icon, flen)) return true; } /* // Search covers in WMTMP if(covers_exist[8]) { - flen = sprintf(icon, "%s/%s", WMTMP, title_id); + flen = concat_path(icon, WMTMP, title_id); if(get_image_file2(icon, flen)) return true; } */ @@ -379,14 +379,14 @@ static void get_default_icon_from_folder(char *icon, u8 is_dir, const char *para { if(is_dir && (webman_config->nocov == SHOW_ICON0)) { - sprintf(icon, "%s/%s/PS3_GAME/ICON0.PNG", param, entry_name); check_ps3_game(icon); + concat_path2(icon, param, entry_name, "/PS3_GAME/ICON0.PNG"); check_ps3_game(icon); if(!HAS(icon)) - sprintf(icon, "%s/%s/ICON0.PNG", param, entry_name); + concat_path2(icon, param, entry_name, "/ICON0.PNG"); return; } // get path/name and remove file extension - sprintf(icon, "%s/%s", param, entry_name); + concat_path(icon, param, entry_name); int flen = remove_ext(icon); if((webman_config->nocov == SHOW_ICON0) && get_image_file(icon, flen)) return; @@ -404,11 +404,11 @@ static void get_default_icon_from_folder(char *icon, u8 is_dir, const char *para char titleid[STD_PATH_LEN]; char *pos = strchr(entry_name, '/'); if(pos) - {*pos = NULL; sprintf(titleid, "%s/%s", entry_name, title_id); *pos = '/';} + {*pos = NULL; concat_path(titleid, entry_name, title_id); *pos = '/';} else strcpy(titleid, title_id); - flen = sprintf(icon, "%s/%s", param, titleid); + flen = concat_path(icon, param, titleid); if(get_image_file2(icon, flen)) return; *icon = NULL; @@ -417,9 +417,9 @@ static void get_default_icon_from_folder(char *icon, u8 is_dir, const char *para // return ICON0 if(is_dir) { - sprintf(icon, "%s/%s/PS3_GAME/ICON0.PNG", param, entry_name); check_ps3_game(icon); + concat_path2(icon, param, entry_name, "/PS3_GAME/ICON0.PNG"); check_ps3_game(icon); if(!HAS(icon)) - sprintf(icon, "%s/%s/ICON0.PNG", param, entry_name); + concat_path2(icon, param, entry_name, "/ICON0.PNG"); return; } @@ -449,7 +449,7 @@ static void get_default_icon_for_iso(char *icon, const char *param, const char * if(is_BIN_ENC(file)) { - flen = sprintf(icon, "%s/%s", param, file); + flen = concat_path(icon, param, file); if(get_image_file(icon, flen)) return; @@ -460,7 +460,7 @@ static void get_default_icon_for_iso(char *icon, const char *param, const char * } } - flen = sprintf(icon, "%s/%s", param, file); + flen = concat_path(icon, param, file); if(not_exists(icon)) { @@ -486,7 +486,7 @@ static void get_default_icon_for_iso(char *icon, const char *param, const char * if(isdir) { if(webman_config->nocov == SHOW_DISC) return; // no icon0 - sprintf(remote_file, "%s/%s/PS3_GAME/ICON0.PNG", param, file); + concat_path2(remote_file, param, file, "/PS3_GAME/ICON0.PNG"); flen = get_name(icon, file, GET_WMTMP); sprintf(icon + flen, ".png"); copy_net_file(icon, remote_file, ns); @@ -495,7 +495,7 @@ static void get_default_icon_for_iso(char *icon, const char *param, const char * else { get_name(icon, file, NO_EXT); - int tlen = sprintf(remote_file, "%s/%s", param, icon); + int tlen = concat_path(remote_file, param, icon); int icon_len = get_name(icon, file, GET_WMTMP); //wmtmp @@ -561,7 +561,7 @@ static enum icon_type get_default_icon(char *icon, const char *param, char *file char filename[STD_PATH_LEN]; if(ns == FROM_MOUNT) - snprintf(filename, STD_PATH_LEN, "%s", file); + strncopy(filename, STD_PATH_LEN, file); else *filename = '\0'; @@ -593,7 +593,7 @@ static enum icon_type get_default_icon(char *icon, const char *param, char *file { default_icon = iPS3; - flen = sprintf(icon, "%s/%s", param + (IS_NET ? 0 : 6), file); + flen = concat_path(icon, param + (IS_NET ? 0 : 6), file); char *ps = strstr(icon, "PS"); if(ps) @@ -722,9 +722,9 @@ static int get_name_iso_or_sfo(char *param_sfo, char *title_id, char *icon, cons { get_name(tempstr, entry_name, NO_EXT); if(IS_NTFS || IS_NET) - sprintf(param_sfo, "%s/%s.SFO", WMTMP, tempstr); // /PS3ISO + concat_path2(param_sfo, WMTMP, tempstr, ".SFO"); // /PS3ISO else - sprintf(param_sfo, "%s/%s.SFO", param, tempstr); // /PS3ISO + concat_path2(param_sfo, param, tempstr, ".SFO"); // /PS3ISO } if(get_title_and_id_from_sfo(title, title_id, entry_name, icon, tempstr, f0) != CELL_FS_SUCCEEDED || !HAS_TITLE_ID) @@ -732,7 +732,7 @@ static int get_name_iso_or_sfo(char *param_sfo, char *title_id, char *icon, cons if(!IS_NTFS) { char *iso_file = param_sfo; - sprintf(iso_file, "%s/%s", param, entry_name); // get raw title ID from ISO + concat_path(iso_file, param, entry_name); // get raw title ID from ISO if(read_file(iso_file, title_id, 11, 0x810) == 11) { @@ -753,7 +753,7 @@ static int get_name_iso_or_sfo(char *param_sfo, char *title_id, char *icon, cons if((f1 == id_PSPISO) && (extcasecmp(entry_name, ".iso", 4))) { - sprintf(iso_file, "%s/%s", param, entry_name); + concat_path(iso_file, param, entry_name); read_file(iso_file, title_id, 10, 0x8373); title_id[10] = 0; } else if(f1 == id_PSXISO || f1 == id_PS2ISO) @@ -764,7 +764,7 @@ static int get_name_iso_or_sfo(char *param_sfo, char *title_id, char *icon, cons if(_IS(ext, ".iso") || _IS(ext, ".bin") || _IS(ext, ".img") || _IS(ext, ".mdf")) { char buf[0x800]; u32 sector; - sprintf(iso_file, "%s/%s", param, entry_name); + concat_path(iso_file, param, entry_name); if(read_file(iso_file, buf, 0x200, 0x8000) == 0x200) { // use CD sector size diff --git a/include/scan/games_html.h b/include/scan/games_html.h index db51443f..26a2aae7 100644 --- a/include/scan/games_html.h +++ b/include/scan/games_html.h @@ -135,7 +135,7 @@ static int add_net_game(int ns, netiso_read_dir_result_data *data, int v3_entry, if(IS_PS3_TYPE) //PS3 games only (0="GAMES", 1="GAMEZ", 2="PS3ISO", 10="video", 11="GAMEI") { if(data[v3_entry].is_directory) - sprintf(local_path, WMTMP "/%s.SFO", data[v3_entry].name); + concat_path2(local_path, WMTMP, data[v3_entry].name, ".SFO"); else {get_name(local_path, data[v3_entry].name, GET_WMTMP); strcat(local_path, ".SFO");} @@ -144,9 +144,9 @@ static int add_net_game(int ns, netiso_read_dir_result_data *data, int v3_entry, if(data[v3_entry].is_directory) { if(IS_GAMEI_FOLDER) - sprintf(remote_path, "%s/%s/PARAM.SFO", param, data[v3_entry].name); + concat_path2(remote_path, param, data[v3_entry].name, "/PARAM.SFO"); else - sprintf(remote_path, "%s/%s/PS3_GAME/PARAM.SFO", param, data[v3_entry].name); + concat_path2(remote_path, param, data[v3_entry].name, "/PS3_GAME/PARAM.SFO"); copy_net_file(local_path, remote_path, ns); @@ -156,7 +156,7 @@ static int add_net_game(int ns, netiso_read_dir_result_data *data, int v3_entry, else { get_name(tempstr, data[v3_entry].name, NO_EXT); - sprintf(remote_path, "%s/%s.SFO", param, tempstr); + concat_path2(remote_path, param, tempstr, ".SFO"); } copy_net_file(local_path, remote_path, ns); } @@ -200,7 +200,7 @@ static int add_net_game(int ns, netiso_read_dir_result_data *data, int v3_entry, if(not_exists(icon)) *icon = NULL; } - sprintf(data[v3_entry].name, "%s", tempstr + strlen(param) + 1); + strcopy(data[v3_entry].name, tempstr + strlen(param) + 1); } add_title_id(title, title_id); @@ -216,9 +216,11 @@ static int add_net_game(int ns, netiso_read_dir_result_data *data, int v3_entry, static void add_query_html(char *buffer, const char *param) { - char html[64], label[8]; - sprintf(label, "%s", param); to_upper(label); - sprintf(html, "[%s] ", param, label); concat(buffer, html); + char html[64]; + sprintf(html,"[%s] ", + param, + to_upper(strfmt("%s", param))); // label + concat(buffer, html); } static int check_drive(u8 f0) @@ -313,14 +315,14 @@ static void set_sort_key(char *skey, char *title, int key, u8 subfolder, u8 f1) { #ifdef LAUNCHPAD if(webman_config->launchpad_grp || (key == HTML_KEY)) - snprintf(skey, HTML_KEY_LEN + 1, "%s", title); + strncopy(skey, HTML_KEY_LEN + 1, title); else { char group = IS_BDISO ? id_VIDEO : get_default_icon_by_type(f1); snprintf(skey, HTML_KEY_LEN + 1, "%c%s", group, title); } #else - snprintf(skey, HTML_KEY_LEN + 1, "%s", title); + strncopy(skey, HTML_KEY_LEN + 1, title); #endif } else @@ -429,9 +431,9 @@ static void set_scan_path(u8 li, u8 f0, u8 f1, u8 is_net, u8 uprofile, char *par else { if(li == LANG_CUSTOM) - sprintf(param, "%s/%s%s", drives[f0], paths[f1], AUTOPLAY_TAG); + concat_path2(param, drives[f0], paths[f1], AUTOPLAY_TAG); else - sprintf(param, "%s/%s%s", drives[f0], paths[f1], SUFIX(uprofile)); + concat_path2(param, drives[f0], paths[f1], SUFIX(uprofile)); // drives: 1="/dev_usb000", 2="/dev_usb001", 3="/dev_usb002", 4="/dev_usb003", 5="/dev_usb006", 6="/dev_usb007", 13="/dev_sd", 14="/dev_ms", 15="/dev_cf" if(f0 && isDir(param) == false) @@ -736,8 +738,8 @@ static bool game_listing(char *buffer, char *templn, char *param, char *tempstr, //if(IS_PS2ISO && f0>0) continue; // PS2ISO is supported only from /dev_hdd0 if(IS_GAMEI_FOLDER) {if((!webman_config->gamei) || (IS_HDD0) || (IS_NTFS)) continue;} - if(IS_ISO_DIR ) {if(is_net) continue; else {sprintf(param, "%s/%s", drives[f0], CUSTOM_PATH1); if(isDir(param)) _f1_ = id_PS2ISO; strcpy(paths[id_ISO], (_f1_ == id_PS2ISO) ? CUSTOM_PATH1 : "ISO");}} - if(IS_VIDEO_FOLDER) {if(is_net) continue; else if(IS_HDD0) strcpy(paths[id_VIDEO], "video"); else {sprintf(param, "%s/%s", drives[f0], CUSTOM_PATH2); if(isDir(param)) _f1_ = id_PS2ISO; strcpy(paths[id_VIDEO], (_f1_ == id_PS2ISO) ? CUSTOM_PATH2 : "GAMES_DUP");}} + if(IS_ISO_DIR ) {if(is_net) continue; else {concat_path(param, drives[f0], CUSTOM_PATH1); if(isDir(param)) _f1_ = id_PS2ISO; strcpy(paths[id_ISO], (_f1_ == id_PS2ISO) ? CUSTOM_PATH1 : "ISO");}} + if(IS_VIDEO_FOLDER) {if(is_net) continue; else if(IS_HDD0) strcpy(paths[id_VIDEO], "video"); else {concat_path(param, drives[f0], CUSTOM_PATH2); if(isDir(param)) _f1_ = id_PS2ISO; strcpy(paths[id_VIDEO], (_f1_ == id_PS2ISO) ? CUSTOM_PATH2 : "GAMES_DUP");}} if(IS_NTFS) {if(f1 >= id_ISO) break; else if(IS_JB_FOLDER || (f1 == id_PSXGAMES)) continue;} // 0="GAMES", 1="GAMEZ", 7="PSXGAMES", 9="ISO", 10="video", 11="GAMEI", 12="ROMS" #ifdef NET_SUPPORT @@ -817,7 +819,7 @@ static bool game_listing(char *buffer, char *templn, char *param, char *tempstr, && !strcasestr(param, filter_name) && !strcasestr(data[v3_entry].name, filter_name)) {v3_entry++; continue;} - if(urlenc(tempstr, icon)) snprintf(icon, STD_PATH_LEN, "%s", tempstr); + if(urlenc(tempstr, icon)) strncopy(icon, STD_PATH_LEN, tempstr); set_sort_key(new_entry->key, title, HTML_KEY - launchpad_mode, 0, f1); // sort key @@ -890,12 +892,12 @@ static bool game_listing(char *buffer, char *templn, char *param, char *tempstr, if(!webman_config->gamei) continue; if(!is_app_dir(param, entry.entry_name.d_name)) continue; - sprintf(param_sfo, "%s/%s/PARAM.SFO", param, entry.entry_name.d_name); + concat_path2(param_sfo, param, entry.entry_name.d_name, "/PARAM.SFO"); } else #endif { - sprintf(param_sfo, "%s/%s/PS3_GAME/PARAM.SFO", param, entry.entry_name.d_name); + concat_path2(param_sfo, param, entry.entry_name.d_name, "/PS3_GAME/PARAM.SFO"); check_ps3_game(param_sfo); } @@ -940,7 +942,7 @@ static bool game_listing(char *buffer, char *templn, char *param, char *tempstr, title[80] = '\0'; // truncate title name - if(urlenc(tempstr, icon)) snprintf(icon, STD_PATH_LEN, "%s", tempstr); + if(urlenc(tempstr, icon)) strncopy(icon, STD_PATH_LEN, tempstr); set_sort_key(new_entry->key, title, HTML_KEY - launchpad_mode, subfolder, f1); // sort key @@ -1069,8 +1071,8 @@ static bool game_listing(char *buffer, char *templn, char *param, char *tempstr, sortable = file_exists(JQUERY_LIB_JS) && file_exists(JQUERY_UI_LIB_JS); if(sortable) { // add external jquery libraries - sprintf(html, SCRIPT_SRC_FMT, JQUERY_LIB_JS); _concat(&sout, html); - sprintf(html, SCRIPT_SRC_FMT, JQUERY_UI_LIB_JS); _concat(&sout, html); + _concat(&sout, strfmt(SCRIPT_SRC_FMT, JQUERY_LIB_JS)); + _concat(&sout, strfmt(SCRIPT_SRC_FMT, JQUERY_UI_LIB_JS)); _concat(&sout, ""); } #endif @@ -1080,7 +1082,7 @@ static bool game_listing(char *buffer, char *templn, char *param, char *tempstr, { if(file_exists(GAMES_SCRIPT_JS)) { - sprintf(html, SCRIPT_SRC_FMT, GAMES_SCRIPT_JS); _concat(&sout, html); + _concat(&sout, strfmt(SCRIPT_SRC_FMT, GAMES_SCRIPT_JS)); } add_html(dat_GET_ICON_SIZE, 0, sout.str, html); } @@ -1143,7 +1145,7 @@ static bool game_listing(char *buffer, char *templn, char *param, char *tempstr, char *mount_path = line_entry[0].path + HTML_KEY_LEN; get_flag(mount_path, "?random="); get_flag(mount_path, "\">"); - sprintf(buffer, "%s%s", "/mount.ps3", mount_path); + concat2(buffer, "/mount.ps3", mount_path); } else if(mobile_mode) { diff --git a/include/scan/games_launchpad.h b/include/scan/games_launchpad.h index 450803bf..7a2644d7 100644 --- a/include/scan/games_launchpad.h +++ b/include/scan/games_launchpad.h @@ -47,7 +47,7 @@ static int add_launchpad_entry(char *buffer, const char *title, const char *url, if(file_exists(icon)) {urlenc(buffer, icon); sprintf(icon, "http://%s%s", local_ip, buffer);} else if(nocover_exists && IS(title_id, "NOID")) sprintf(icon, "http://%s%s", local_ip, WM_ICONS_PATH "/icon_lp_nocover.png"); - else sprintf(icon, "%s/%s%s", LAUNCHPAD_COVER_SVR, title_id, strstr(title_id, ".png") ? "" : ".JPG"); + else concat_path2(icon, LAUNCHPAD_COVER_SVR, title_id, strstr(title_id, ".png") ? "" : ".JPG"); int size; char *new_entry = buffer; @@ -95,12 +95,12 @@ static void add_launchpad_footer(char *buffer) { char server_url[64]; char *icon_path = buffer; - sprintf(icon_path, "%s/blank.png", WM_ICONS_PATH); + concat2(icon_path, WM_ICONS_PATH, "/blank.png"); if(file_exists(icon_path)) sprintf(server_url, "http://%s%s", local_ip, WM_ICONS_PATH); else - sprintf(server_url, "%s", LAUNCHPAD_COVER_SVR); + strcopy(server_url, LAUNCHPAD_COVER_SVR); // --- add scroller placeholder u16 size = sprintf(buffer, "\n" diff --git a/include/scan/games_slaunch.h b/include/scan/games_slaunch.h index 8581543f..0a12499d 100644 --- a/include/scan/games_slaunch.h +++ b/include/scan/games_slaunch.h @@ -54,7 +54,7 @@ static void add_slaunch_entry(int fd, const char *neth, const char *path, const (slaunch.type == TYPE_PSP) ? id_PSPISO : (slaunch.type == TYPE_VID) ? id_BDISO : id_ROMS; - sprintf(enc_filename, "%s%s/", "/dev_usb000/PICTURE/", paths[f1]); cellFsMkdir(enc_filename, DMODE); + concat_path(enc_filename, "/dev_usb000/PICTURE", paths[f1]); cellFsMkdir(enc_filename, DMODE); strcat(enc_filename, filename); strcat(enc_filename, strcasestr(icon, ".png") ? ".PNG" : ".JPG"); @@ -62,14 +62,14 @@ static void add_slaunch_entry(int fd, const char *neth, const char *path, const } #endif - snprintf(slaunch.id, sizeof(slaunch.id), "%s", id); urlenc_ex(enc_filename, filename, false); + strncopy(slaunch.id, sizeof(slaunch.id), id); urlenc_ex(enc_filename, filename, false); - slaunch.path_pos = snprintf(slaunch.name, 128, "%s", name) + 1; + slaunch.path_pos = strncopy(slaunch.name, 128, name) + 1; if(slaunch.type == TYPE_PS2 && strcasestr(filename, ".BIN.ENC")) c = '.'; else c = '_'; slaunch.icon_pos = snprintf(slaunch.name + slaunch.path_pos, 454 - slaunch.path_pos, "/mount%cps3%s%s/%s", c, neth, path, enc_filename) + slaunch.path_pos + 1; - snprintf(slaunch.name + slaunch.icon_pos, 507 - slaunch.icon_pos, "%s", icon); + strncopy(slaunch.name + slaunch.icon_pos, 507 - slaunch.icon_pos, icon); cellFsWrite(fd, (void *)&slaunch, sizeof(_slaunch), NULL); } @@ -94,7 +94,7 @@ static int find_slaunch_game(char *filename, u8 offset) { char *path = slaunch.name + slaunch.path_pos; if((strcasestr(path, filename2) == NULL) && (strcasestr(name, filename) == NULL)) continue; - ret = sprintf(filename, "%s", path + offset); break; + ret = strcopy(filename, path + offset); break; } cellFsClose(fsl); } diff --git a/include/scan/games_xml.h b/include/scan/games_xml.h index 58e55e5b..3baa9775 100644 --- a/include/scan/games_xml.h +++ b/include/scan/games_xml.h @@ -809,7 +809,7 @@ static bool scan_mygames_xml(u64 conn_s_p) // --- build group headers --- char *tempstr, *table_xml, *folder_name; table_xml = tempstr = sysmem_xml; folder_name = sysmem_xml + (3*KB); - char localhost[2]; sprintf(localhost, "0"); //sprintf(localhost, "http://%s", local_ip); // "0" = localhost + char localhost[2]; strcopy(localhost, "0"); //sprintf(localhost, "http://%s", local_ip); // "0" = localhost const char *proxy_include = (char*)WEB_LINK_INC; #ifdef WM_PROXY_SPRX if((cobra_version > 0) && file_exists(WM_PROXY) && !(webman_config->wm_proxy)) {proxy_include = (char*)XAI_LINK_INC, *localhost = NULL;} @@ -930,8 +930,8 @@ static bool scan_mygames_xml(u64 conn_s_p) //if(IS_PS2ISO && f0>0) continue; // PS2ISO is supported only from /dev_hdd0 if(IS_GAMEI_FOLDER) {if((!webman_config->gamei) || (IS_HDD0) || (IS_NTFS)) continue;} - if(IS_ISO_DIR ) {if(is_net) continue; else {sprintf(param, "%s/%s", drives[f0], CUSTOM_PATH1); if(isDir(param)) _f1_ = id_PS2ISO; strcpy(paths[id_ISO], (_f1_ == id_PS2ISO) ? CUSTOM_PATH1 : "ISO");}} - if(IS_VIDEO_FOLDER) {if(is_net) continue; else if(IS_HDD0) strcpy(paths[id_VIDEO], "video"); else {sprintf(param, "%s/%s", drives[f0], CUSTOM_PATH2); if(isDir(param)) _f1_ = id_PS2ISO; strcpy(paths[id_VIDEO], (_f1_ == id_PS2ISO) ? CUSTOM_PATH2 : "GAMES_DUP");}} + if(IS_ISO_DIR ) {if(is_net) continue; else {concat_path(param, drives[f0], CUSTOM_PATH1); if(isDir(param)) _f1_ = id_PS2ISO; strcpy(paths[id_ISO], (_f1_ == id_PS2ISO) ? CUSTOM_PATH1 : "ISO");}} + if(IS_VIDEO_FOLDER) {if(is_net) continue; else if(IS_HDD0) strcpy(paths[id_VIDEO], "video"); else {concat_path(param, drives[f0], CUSTOM_PATH2); if(isDir(param)) _f1_ = id_PS2ISO; strcpy(paths[id_VIDEO], (_f1_ == id_PS2ISO) ? CUSTOM_PATH2 : "GAMES_DUP");}} if(IS_NTFS) {if(f1 >= id_ISO) break; else if(IS_JB_FOLDER || (f1 == id_PSXGAMES)) continue;} // 0="GAMES", 1="GAMEZ", 7="PSXGAMES", 9="ISO", 10="video", 11="GAMEI", 12="ROMS" #ifdef NET_SUPPORT @@ -1004,7 +1004,7 @@ static bool scan_mygames_xml(u64 conn_s_p) if(isDir(param) == false) { char *roms_folder = tempstr; - sprintf(roms_folder, "%s", cur_roms_path); *roms_folder ^= 0x20; // capitalize first letter of folder name (e.g. /ROMS/Snes) + strcopy(roms_folder, cur_roms_path); *roms_folder ^= 0x20; // capitalize first letter of folder name (e.g. /ROMS/Snes) sprintf(param, "%s/ROMS%s/%s", drives[f0], SUFIX(uprofile), roms_folder); if(isDir(param) == false) continue; @@ -1098,14 +1098,14 @@ static bool scan_mygames_xml(u64 conn_s_p) if(!webman_config->gamei) continue; if(!is_app_dir(param, entry.entry_name.d_name)) continue; - sprintf(param_sfo, "%s/%s/PARAM.SFO", param, entry.entry_name.d_name); + concat_path2(param_sfo, param, entry.entry_name.d_name, "/PARAM.SFO"); // create game folder in /dev_hdd0/game and copy PARAM.SFO to prevent deletion of XMB icon when gameDATA is disabled char *hdd_game_sfo = tempstr; if((entry.entry_name.d_namlen >= 16) && (entry.entry_name.d_name[6] == '-')) sprintf(hdd_game_sfo, "%s%.9s/PARAM.SFO", _HDD0_GAME_DIR, entry.entry_name.d_name + 7); // convert content_id => title_id else - sprintf(hdd_game_sfo, "%s/%s/PARAM.SFO", _HDD0_GAME_DIR, entry.entry_name.d_name); // title_id + concat_path2(hdd_game_sfo, _HDD0_GAME_DIR, entry.entry_name.d_name, "/PARAM.SFO"); // title_id if(not_exists(hdd_game_sfo)) { @@ -1119,10 +1119,10 @@ static bool scan_mygames_xml(u64 conn_s_p) else #endif // #ifdef MOUNT_GAMEI if(is_game_dir) - read_e = sprintf(param_sfo, "%s/%s/USRDIR/EBOOT.BIN", param, entry.entry_name.d_name); + read_e = concat_path2(param_sfo, param, entry.entry_name.d_name, "/USRDIR/EBOOT.BIN"); else { - sprintf(param_sfo, "%s/%s/PS3_GAME/PARAM.SFO", param, entry.entry_name.d_name); + concat_path2(param_sfo, param, entry.entry_name.d_name, "/PS3_GAME/PARAM.SFO"); check_ps3_game(param_sfo); } @@ -1140,7 +1140,7 @@ static bool scan_mygames_xml(u64 conn_s_p) if(!is_iso) // IS_JB_FOLDER { - if(is_game_dir) sprintf(param_sfo + read_e - 17, "/PARAM.SFO"); + if(is_game_dir) strcopy(param_sfo + read_e - 17, "/PARAM.SFO"); if(webman_config->info & INFO_VER) getTitleID(param_sfo, app_ver, GET_VERSION); get_title_and_id_from_sfo(title, title_id, entry.entry_name.d_name, icon, tempstr, 0); @@ -1496,7 +1496,7 @@ static bool scan_mygames_xml(u64 conn_s_p) #endif } } - slen = sprintf(buffer, "\r\n"); + slen = strcopy(buffer, "\r\n"); } cellFsWrite(fdxml, (char*)buffer, slen, NULL); @@ -1652,20 +1652,24 @@ static void refresh_xml(char *msg) { #ifndef LITE_EDITION if(webman_config->lang > 6) - snprintf(msg, 200, "%s:\n%s - %'i", STR_SCAN2, STR_GAMES, games_found); + snprintf(msg, 200, "%s:\n" + "%s - %'i", STR_SCAN2, STR_GAMES, games_found); else #endif - snprintf(msg, 200, "%s:\n %'i %s", STR_SCAN2, games_found, STR_GAMES); + snprintf(msg, 200, "%s:\n" + " %'i %s", STR_SCAN2, games_found, STR_GAMES); show_msg_with_icon(ICON_WAIT, msg); } } #ifndef LITE_EDITION if(webman_config->lang > 6) - sprintf(msg, "%s XML%s: OK\n%s - %'i ", STR_REFRESH, SUFIX2(profile), STR_GAMES, games_found); + sprintf(msg, "%s XML%s: OK\n" + "%s - %'i ", STR_REFRESH, SUFIX2(profile), STR_GAMES, games_found); else #endif - sprintf(msg, "%s XML%s: OK\n%'i %s", STR_REFRESH, SUFIX2(profile), games_found, STR_GAMES); + sprintf(msg, "%s XML%s: OK\n" + "%'i %s", STR_REFRESH, SUFIX2(profile), games_found, STR_GAMES); show_msg_with_icon(ICON_GAME, msg); if(!webman_config->nobeep) play_sound_id(5); diff --git a/include/scan/prepntfs.h b/include/scan/prepntfs.h index d41d9e8c..6469c720 100644 --- a/include/scan/prepntfs.h +++ b/include/scan/prepntfs.h @@ -58,7 +58,7 @@ static void create_ntfs_file(char *iso_path, char *filename, size_t plen) // get multi-part file sectors if(is_iso_0(filename)) { - size_t nlen = sprintf(tmp_path, "%s", iso_path); + size_t nlen = strcopy(tmp_path, iso_path); extlen = 6, --nlen; int nparts; for(u8 o = 1; o < 64; o++) @@ -190,7 +190,7 @@ static void create_ntfs_file(char *iso_path, char *filename, size_t plen) } // copy .PNG and .SFO from NTFS drive - int tlen = sprintf(tmp_path, "%s/%s", WMTMP, filename); + int tlen = concat_path(tmp_path, WMTMP, filename); // copy external .SFO to WMTMP if exists if((ntfs_m == id_PS3ISO) && !sfo_found) @@ -251,11 +251,11 @@ static void scan_path_ntfs(const char *path, bool chk_dirs) while(ps3ntfs_dirnext(pdir, dir.d_name, &st) == 0) { if(dir.d_name[0] == '.') continue; - size_t flen = snprintf(dir_entry + plen, STD_PATH_LEN - plen, "%s", dir.d_name); + size_t flen = strncopy(dir_entry + plen, STD_PATH_LEN - plen, dir.d_name); if(st.st_mode & S_IFDIR) { - if(idx < max_entries) {sprintf(dir_entries[idx++].path, "%s", dir.d_name);} + if(idx < max_entries) {strcopy(dir_entries[idx++].path, dir.d_name);} } else if(is_iso_file(dir.d_name, flen, ntfs_m, 0)) { @@ -266,7 +266,7 @@ static void scan_path_ntfs(const char *path, bool chk_dirs) for(int i = 0; i < idx; i++) { - snprintf(dir_entry + plen, STD_PATH_LEN - plen, "%s", dir_entries[i].path); + strncopy(dir_entry + plen, STD_PATH_LEN - plen, dir_entries[i].path); ntfs_subdir = dir_entries[i].path; for(int c = 0; ntfs_subdir[c]; c++) diff --git a/include/scan/snd0.h b/include/scan/snd0.h index 119875ba..fdc1cc4c 100644 --- a/include/scan/snd0.h +++ b/include/scan/snd0.h @@ -19,8 +19,8 @@ static void snd0_thread(__attribute__((unused)) u64 arg) { if(cellFsGetDirectoryEntries(fd, &entry, sizeof(entry), &read_e) || !read_e) break; if(entry.entry_name.d_namlen != TITLE_ID_LEN) continue; - sprintf(snd0_file, "%s/SND0.AT3", entry.entry_name.d_name); cellFsChmod(snd0_file, mode); - sprintf(snd0_file, "%s/ICON1.PAM", entry.entry_name.d_name); cellFsChmod(snd0_file, mode); + concat2(snd0_file, entry.entry_name.d_name, "/SND0.AT3"); cellFsChmod(snd0_file, mode); + concat2(snd0_file, entry.entry_name.d_name, "/ICON1.PAM"); cellFsChmod(snd0_file, mode); } cellFsClosedir(fd); } diff --git a/include/setup.h b/include/setup.h index e4523f71..0d0fe39c 100644 --- a/include/setup.h +++ b/include/setup.h @@ -44,7 +44,7 @@ static void setup_parse_settings(char *param) get_param("&autop=", webman_config->autoboot_path, param, 255); - if((webman_config->autoboot_path[0] != '/') && !islike(webman_config->autoboot_path, "http")) sprintf(webman_config->autoboot_path, "%s", DEFAULT_AUTOBOOT_PATH); + if((webman_config->autoboot_path[0] != '/') && !islike(webman_config->autoboot_path, "http")) strcopy(webman_config->autoboot_path, DEFAULT_AUTOBOOT_PATH); webman_config->usb0 = IS_MARKED("u0=1"); webman_config->usb1 = IS_MARKED("u1=1"); @@ -552,20 +552,20 @@ static void setup_form(char *buffer, char *html) syscalls_removed = CFW_SYSCALLS_REMOVED(TOC); if(syscalls_removed) { - sprintf(html, "

%s

%s", STR_CFWSYSALRD, HTML_RED_SEPARATOR); concat(buffer, html); + concat(buffer, strfmt("

%s

%s", STR_CFWSYSALRD, HTML_RED_SEPARATOR)); } #ifdef COBRA_ONLY else if(!cobra_version) { - sprintf(html, "

%s %s

%s", "Cobra", STR_DISABLED, HTML_RED_SEPARATOR); concat(buffer, html); + concat(buffer, strfmt("

%s %s

%s", "Cobra", STR_DISABLED, HTML_RED_SEPARATOR)); } #endif u8 value, b, h = is_app_home_onxmb(); add_html(dat_SETUP_FORM, 0, buffer, html); - sprintf(html, " %s
" - "" - "
", STR_SCAN2); concat(buffer, html); + concat(buffer, strfmt(" %s
" + "" + "
", STR_SCAN2)); //Scan these devices if(!isDir("/dev_hdd0/GAMEZ") && h) @@ -644,9 +644,9 @@ static void setup_form(char *buffer, char *html) sprintf(_nd, "nd%i", id); sprintf(_neth, "neth%i", id); sprintf(_netp, "netp%i", id); add_checkbox(_nd, STR_LANGAMES, PS3NETSRV, (webman_config->netd[id]), buffer); - sprintf(html, HTML_INPUT("%s", "%s", "15", "16") ":" HTML_PORT("%s", "%i") "
", - _neth, webman_config->neth[id], - _netp, webman_config->netp[id]); concat(buffer, html); + concat(buffer, strfmt(HTML_INPUT("%s", "%s", "15", "16") ":" HTML_PORT("%s", "%i") "
", + _neth, webman_config->neth[id], + _netp, webman_config->netp[id])); ++PS3NETSRV[21], ++PS3NETSRV[75]; } add_checkbox_line("nsd", "Scan remote sub-directories", !(webman_config->nsd), buffer); @@ -680,12 +680,12 @@ static void setup_form(char *buffer, char *html) #ifndef LITE_EDITION concat(buffer, "
"); add_checkbox("ct", "CPU/RSX/FAN Chart", " ", (webman_config->chart), buffer); - if(file_exists(CPU_RSX_CHART)) {sprintf(html, HTML_URL, CPU_RSX_CHART, "👓"); concat(buffer, html);} + if(file_exists(CPU_RSX_CHART)) {concat(buffer, strfmt(HTML_URL, CPU_RSX_CHART, "👓"));} #endif concat(buffer, "
"); //general settings - sprintf(html, "%scfg);\"> " WM_APPNAME " MOD %s
", HTML_TOGGLER, STR_SETUP); concat(buffer, html); + concat(buffer, strfmt("%scfg);\"> " WM_APPNAME " MOD %s
", HTML_TOGGLER, STR_SETUP)); add_checkbox("lp", STR_LPG , " • ", (webman_config->lastp), buffer); add_checkbox("nb", "BEEP", " • ", !(webman_config->nobeep), buffer); @@ -713,27 +713,27 @@ static void setup_form(char *buffer, char *html) concat(buffer, HTML_BLU_SEPARATOR); add_checkbox("ft", STR_FTPSVC, " : ", (webman_config->ftpd) , buffer); - sprintf(html, HTML_PORT("ff", "%i") " • Timeout ", webman_config->ftp_port); concat(buffer, html); + concat(buffer, strfmt(HTML_PORT("ff", "%i") " • Timeout ", webman_config->ftp_port)); #ifdef AUTO_POWER_OFF - sprintf(html, HTML_NUMBER("tm", "%i", "0", "255") " mins • ", webman_config->ftp_timeout); concat(buffer, html); + concat(buffer, strfmt(HTML_NUMBER("tm", "%i", "0", "255") " mins • ", webman_config->ftp_timeout)); add_checkbox_line("pw", "No Auto Power Off", !(webman_config->auto_power_off), buffer); #else - sprintf(html, HTML_NUMBER("tm", "%i", "0", "255") " mins
", webman_config->ftp_timeout); concat(buffer, html); + concat(buffer, strfmt(HTML_NUMBER("tm", "%i", "0", "255") " mins
", webman_config->ftp_timeout)); #endif #ifdef PS3NET_SERVER - sprintf(html, "%s", STR_FTPSVC); char *pos = strcasestr(html, "FTP"); if(pos) {pos[0] = 'N', pos[1] = 'E', pos[2] = 'T';} + strcopy(html, STR_FTPSVC); char *pos = strcasestr(html, "FTP"); if(pos) {pos[0] = 'N', pos[1] = 'E', pos[2] = 'T';} add_checkbox("nd", html, " : ", (webman_config->netsrvd) , buffer); - sprintf(html, HTML_PORT("ndp", "%i") "
", webman_config->netsrvp); concat(buffer, html); + concat(buffer, strfmt(HTML_PORT("ndp", "%i") "
", webman_config->netsrvp)); #endif add_checkbox("bn", STR_ACCESS, " : ", (webman_config->bind) , buffer); - char pwd[24]; _memset(pwd, sizeof(pwd)); memcpy(pwd, webman_config->ftp_password, 20); + char pwd[24]; strncopy(pwd, 20, webman_config->ftp_password); - sprintf(html, HTML_INPUT("aip", "%s", "15", "16") " Pwd: " - HTML_PASSW("pwd", "%s", "20", "20") "
", webman_config->allow_ip, pwd); concat(buffer, html); + concat(buffer, strfmt( HTML_INPUT("aip", "%s", "15", "16") " Pwd: " + HTML_PASSW("pwd", "%s", "20", "20") "
", webman_config->allow_ip, pwd)); concat(buffer, HTML_BLU_SEPARATOR); @@ -800,7 +800,7 @@ static void setup_form(char *buffer, char *html) #ifndef ENGLISH_ONLY //language - sprintf(html, " • %s: ", STR_PLANG); concat(buffer, html); + concat(buffer, strfmt(" • %s: ", STR_PLANG)); add_html(dat_LANGUAGES, webman_config->lang, buffer, html); #endif concat(buffer, "
"); @@ -858,31 +858,31 @@ static void setup_form(char *buffer, char *html) //general settings #ifdef SPOOF_CONSOLEID - sprintf(html, "%sadv);\"> IDPS & MEM %s
", HTML_TOGGLER, STR_SETUP); concat(buffer, html); + concat(buffer, strfmt("%sadv);\"> IDPS & MEM %s
", HTML_TOGGLER, STR_SETUP)); #else - sprintf(html, "%sadv);\"> MEM %s
", HTML_TOGGLER, STR_SETUP); concat(buffer, html); + concat(buffer, strfmt("%sadv);\"> MEM %s
", HTML_TOGGLER, STR_SETUP)); #endif #ifdef SPOOF_CONSOLEID concat(buffer, ""); - char tmp[80]; + char *tmp = html; sprintf(tmp, "%016llX';vID2.value='%016llX", eid0_idps[0], eid0_idps[1]); add_checkbox("id1", "IDPS", " : ", (webman_config->sidps), buffer); - sprintf(html, HTML_INPUT("%s", "%s", "16", "22"), "vID1", webman_config->vIDPS1); concat(buffer, html); - sprintf(html, HTML_INPUT("%s", "%s", "16", "22"), "vID2", webman_config->vIDPS2); concat(buffer, html); + concat(buffer, strfmt(HTML_INPUT("%s", "%s", "16", "22"), "vID1", webman_config->vIDPS1)); + concat(buffer, strfmt(HTML_INPUT("%s", "%s", "16", "22"), "vID2", webman_config->vIDPS2)); //sprintf(html, HTML_BUTTON_FMT "
", HTML_BUTTON, " ", "onclick=\"if(t=='ht')h();vID2.value=", "1000000000000000"); concat(buffer, html); - sprintf(html, HTML_BUTTON_FMT "
", HTML_BUTTON, " ", "onclick=\"if(t=='ht')h();vID1.value=", tmp); concat(buffer, html); + concat(buffer, strfmt(HTML_BUTTON_FMT "
", HTML_BUTTON, " ", "onclick=\"if(t=='ht')h();vID1.value=", tmp)); sprintf(tmp, "%016llX';vPS2.value='%016llX", PSID[0], PSID[1]); add_checkbox("id2", "PSID", " : ", (webman_config->spsid), buffer); - sprintf(html, HTML_INPUT("%s", "%s", "16", "22"), "vPS1", webman_config->vPSID1); concat(buffer, html); - sprintf(html, HTML_INPUT("%s", "%s", "16", "22"), "vPS2", webman_config->vPSID2); concat(buffer, html); + concat(buffer, strfmt(HTML_INPUT("%s", "%s", "16", "22"), "vPS1", webman_config->vPSID1)); + concat(buffer, strfmt(HTML_INPUT("%s", "%s", "16", "22"), "vPS2", webman_config->vPSID2)); //sprintf(html, HTML_BUTTON_FMT "

", HTML_BUTTON, " ", "onclick=\"vPS1.value=vPS2.value=", "0000000000000000"); concat(buffer, html); //sprintf(html, HTML_BUTTON_FMT, HTML_BUTTON, " ", "onclick=\"if(t=='ht')h();vPS1.value=vPS2.value=", "0000000000000000"); concat(buffer, html); - sprintf(html, HTML_BUTTON_FMT, HTML_BUTTON, " ", "onclick=\"if(t=='ht')h();vPS1.value=", tmp); concat(buffer, html); + concat(buffer, strfmt(HTML_BUTTON_FMT, HTML_BUTTON, " ", "onclick=\"if(t=='ht')h();vPS1.value=", tmp)); add_html(dat_VIEW_IDPS, 0, buffer, html); #endif @@ -910,7 +910,7 @@ static void setup_form(char *buffer, char *html) #ifndef LITE_EDITION //default content profile - sprintf(html, "%s : ", STR_PROFILE)); add_option_item(0 , STR_DEFAULT, (profile == 0) , buffer); char profile_id[] = {'1', 0}; for(u8 usr = 1; usr <= 4; ++usr, ++profile_id[0]) @@ -921,7 +921,7 @@ static void setup_form(char *buffer, char *html) //default user account if(!webman_config->uaccount[0]) sprintf(webman_config->uaccount, "%08i", xusers()->GetCurrentUserNumber()); - sprintf(html, " : %s : %s" - "" - "", STR_SAVE); concat(buffer, html); + concat(buffer, strfmt(HTML_RED_SEPARATOR + "" + "" + "", STR_SAVE)); #ifndef LITE_EDITION #ifdef PKG_HANDLER @@ -1345,7 +1342,7 @@ static void read_settings(void) #endif // set default autoboot path - if((webman_config->autoboot_path[0] != '/') && !islike(webman_config->autoboot_path, "http")) sprintf(webman_config->autoboot_path, "%s", DEFAULT_AUTOBOOT_PATH); + if((webman_config->autoboot_path[0] != '/') && !islike(webman_config->autoboot_path, "http")) strcopy(webman_config->autoboot_path, DEFAULT_AUTOBOOT_PATH); // check stored data if(webman_config->maxfan < 40) webman_config->maxfan = 80; // % (0xCC) diff --git a/include/www/www_admin.h b/include/www/www_admin.h index 1c6675e8..adcf6e76 100644 --- a/include/www/www_admin.h +++ b/include/www/www_admin.h @@ -63,7 +63,7 @@ if(!accept) { - sprintf(param, "%s\nADMIN %s", STR_ERROR, STR_DISABLED); + concat3(param, STR_ERROR, "\nADMIN ", STR_DISABLED); keep_alive = http_response(conn_s, header, param, CODE_BAD_REQUEST, param); goto exit_handleclient_www; } diff --git a/include/www/www_client.h b/include/www/www_client.h index 0b10f78a..ae4365b9 100644 --- a/include/www/www_client.h +++ b/include/www/www_client.h @@ -135,7 +135,7 @@ static int http_response(int conn_s, char *header, const char *url, int code, co } #endif else - strcpy(body, msg); + strcopy(body, msg); if(code == CODE_PATH_NOT_FOUND) { @@ -146,24 +146,24 @@ static int http_response(int conn_s, char *header, const char *url, int code, co if(css_exists) { - sprintf(header, "", COMMON_CSS); strcat(body, header); + sprintf(header, "", COMMON_CSS); concat(body, header); } if(common_js_exists) { - sprintf(header, SCRIPT_SRC_FMT, COMMON_SCRIPT_JS); strcat(body, header); + sprintf(header, SCRIPT_SRC_FMT, COMMON_SCRIPT_JS); concat(body, header); } #ifdef PATCH_ROS if(done) { sprintf(header, "
" HTML_BUTTON_FMT "%s", - HTML_BUTTON, " ◀ ", HTML_ONCLICK, ((code == CODE_RETURN_TO_ROOT) ? "/" : "javascript:history.back();"), HTML_BODY_END); strcat(body, header); + HTML_BUTTON, " ◀ ", HTML_ONCLICK, ((code == CODE_RETURN_TO_ROOT) ? "/" : "javascript:history.back();"), HTML_BODY_END); concat(body, header); } else - strcat(body, "
"); + concat(body, "
"); #else sprintf(header, "
" HTML_BUTTON_FMT "%s", - HTML_BUTTON, " ◀ ", HTML_ONCLICK, ((code == CODE_RETURN_TO_ROOT) ? "/" : "javascript:history.back();"), HTML_BODY_END); strcat(body, header); + HTML_BUTTON, " ◀ ", HTML_ONCLICK, ((code == CODE_RETURN_TO_ROOT) ? "/" : "javascript:history.back();"), HTML_BODY_END); concat(body, header); #endif slen = sprintf(header, HTML_RESPONSE_FMT, @@ -201,16 +201,16 @@ static size_t prepare_html(char *buffer, char *html, char *param, u8 is_ps3_http if(webman_config->lang) { _concat(&sbuffer, "", STR_MYGAMES); _concat(&sbuffer, html); + _concat(&sbuffer, strfmt("l('%s','%s');", "games", STR_GAMES)); + _concat(&sbuffer, strfmt("l('%s','%s');", "files", STR_FILES)); + _concat(&sbuffer, strfmt("l('%s','%s');", "setup", STR_SETUP)); + _concat(&sbuffer, strfmt("l('%s','%s');", "eject", STR_EJECT)); + _concat(&sbuffer, strfmt("l('%s','%s');", "insert", STR_INSERT)); + _concat(&sbuffer, strfmt("l('%s','%s');", "refresh", STR_REFRESH)); + _concat(&sbuffer, strfmt("l('%s','%s');", "restart", STR_RESTART)); + _concat(&sbuffer, strfmt("l('%s','%s');", "shutdown", STR_SHUTDOWN)); + _concat(&sbuffer, strfmt("l('msg2','%s ...');" + "", STR_MYGAMES)); } #endif @@ -224,7 +224,7 @@ static size_t prepare_html(char *buffer, char *html, char *param, u8 is_ps3_http } } - if(param[1] && !strstr(param, ".ps3")) {_concat(&sbuffer, ""); _concat(&sbuffer, html);} + if(param[1] && !strstr(param, ".ps3")) {urlenc(html, param); _concat3(&sbuffer, "");} return sbuffer.size; } @@ -264,7 +264,9 @@ static size_t prepare_html(char *buffer, char *html, char *param, u8 is_ps3_http const char *coverflow = NULL; if(file_exists(MOBILE_HTML)) coverflow = (char*)" [Coverflow]"; - size_t tlen = sprintf(html, "" WM_APP_VERSION "
[%s] [%s]%s", STR_FILES, (webman_config->sman && file_exists(HTML_BASE_PATH "/sman.htm")) ? "/sman.ps3" : "/index.ps3", STR_GAMES, coverflow); + size_t tlen = sprintf(html, "" WM_APP_VERSION "
" + "[%s] [%s]%s", STR_FILES, + (webman_config->sman && file_exists(HTML_BASE_PATH "/sman.htm")) ? "/sman.ps3" : "/index.ps3", STR_GAMES, coverflow); #ifdef SYS_ADMIN_MODE if(sys_admin) @@ -286,7 +288,7 @@ static size_t prepare_html(char *buffer, char *html, char *param, u8 is_ps3_http #ifdef SYS_ADMIN_MODE } else - strcat(html, "
"); + strcat(html + tlen, "
"); #endif _concat(&sbuffer, html); @@ -324,7 +326,7 @@ static void do_web_command(u64 conn_s_p, const char *wm_url) sys_net_get_sockinfo(conn_s, &conn_info, 1); char *remote_ip = cmd; - sprintf(remote_ip, "%s", inet_ntoa(conn_info.remote_adr)); + strcopy(remote_ip, inet_ntoa(conn_info.remote_adr)); // check remote access if(webman_config->bind && is_remote_ip && !islike(remote_ip, webman_config->allow_ip)) @@ -431,7 +433,7 @@ static void do_web_command(u64 conn_s_p, const char *wm_url) if(*header == '/') buf.st_size = snprintf(header, HTML_RECV_SIZE, "GET %s", wm_url); else - buf.st_size = snprintf(header, HTML_RECV_SIZE, "%s", wm_url); + buf.st_size = strncopy(header, HTML_RECV_SIZE, wm_url); } replace_char(header, '\t', ' '); @@ -459,7 +461,7 @@ static void do_web_command(u64 conn_s_p, const char *wm_url) // add /mount_ps3 prefix strcpy(param, photo_path); - sprintf(photo_path, "/mount_ps3%s", param); + concat2(photo_path, "/mount_ps3", param); } } else @@ -609,6 +611,7 @@ static void do_web_command(u64 conn_s_p, const char *wm_url) #include "../cmd/unlockhdd.h" #include "../cmd/unlocksave.h" #include "../cmd/bdinfo.h" + #include "../cmd/err.h" } #ifdef COPY_PS3 if(islike(param, "/copy")) {dont_copy_same_size = (param[5] == '.'); param[5] = '.';} //copy_ps3 -> force copy files of the same file size diff --git a/include/www/www_listing.h b/include/www/www_listing.h index ef184d6d..07f45be8 100644 --- a/include/www/www_listing.h +++ b/include/www/www_listing.h @@ -72,7 +72,7 @@ goto html_response; } - if(islike(param, "/favicon.ico")) {sprintf(param, "%s", wm_icons[iPS3]);} + if(islike(param, "/favicon.ico")) {strcopy(param, wm_icons[iPS3]);} else check_path_alias(param); is_binary = is_ntfs || (cellFsStat(param, &buf) == CELL_FS_SUCCEEDED); allow_retry_response = true; @@ -91,9 +91,8 @@ cellFsUnlink(FILE_LIST); if(reply_html) { - sprintf(header, SCRIPT_SRC_FMT, FS_SCRIPT_JS); save_file(FILE_LIST, HTML_HEADER, SAVE_ALL); - save_file(FILE_LIST, header, APPEND_TEXT); + save_file(FILE_LIST, strfmt(SCRIPT_SRC_FMT, FS_SCRIPT_JS), APPEND_TEXT); save_file(FILE_LIST, "
", APPEND_TEXT);
 		}
 
diff --git a/include/www/www_start.h b/include/www/www_start.h
index cb7f70de..2efc1ad0 100644
--- a/include/www/www_start.h
+++ b/include/www/www_start.h
@@ -65,18 +65,18 @@ static void start_www(u64 conn_s_p)
 		{
 			if(not_exists(wm_icons[i]))
 			{	// Check /dev_flash/vsh/resource/explore/icon/
-				sprintf(icon_path, VSH_RESOURCE_DIR "explore/icon/%s", wm_icons[i] + 23); strcpy(wm_icons[i], icon_path);
+				concat_path(icon_path, VSH_RESOURCE_DIR "explore/icon", wm_icons[i] + 23); strcpy(wm_icons[i], icon_path);
 				if(file_exists(icon_path)) continue;
 
 				// If not found, use /dev_flash/vsh/resource/explore/user/
 				char *icon = wm_icons[i] + 32;
-				if(i == gPS3 || i == iPS3)	sprintf(icon, "user/024.png"); else // ps3
-				if(i == gPSX || i == iPSX)	sprintf(icon, "user/026.png"); else // psx
-				if(i == gPS2 || i == iPS2)	sprintf(icon, "user/025.png"); else // ps2
-				if(i == gPSP || i == iPSP)	sprintf(icon, "user/022.png"); else // psp
-				if(i == gDVD || i == iDVD)	sprintf(icon, "user/023.png"); else // dvd
-				if(i == iROM || i == iBDVD)	strcpy(wm_icons[i], wm_icons[iPS3]); else
-											sprintf(icon + 5, "icon_home.png"); // setup / eject
+				if(i == gPS3 || i == iPS3)	strcopy(icon, "user/024.png"); else // ps3
+				if(i == gPSX || i == iPSX)	strcopy(icon, "user/026.png"); else // psx
+				if(i == gPS2 || i == iPS2)	strcopy(icon, "user/025.png"); else // ps2
+				if(i == gPSP || i == iPSP)	strcopy(icon, "user/022.png"); else // psp
+				if(i == gDVD || i == iDVD)	strcopy(icon, "user/023.png"); else // dvd
+				if(i == iROM || i == iBDVD)	strcopy(wm_icons[i], wm_icons[iPS3]); else
+											strcopy(icon + 5, "icon_home.png"); // setup / eject
 			}
 		}
 		#endif
diff --git a/main.c b/main.c
index b9043378..53600636 100644
--- a/main.c
+++ b/main.c
@@ -70,7 +70,7 @@ static char search_url[50];
  #ifdef LITE_EDITION
 	#define EDITION_ " [Lite]"
 	#define _EDITION EDITION_
- #elif defined(PS3NET_SERVER) && defined(NET3NET4) && defined(XMB_SCREENSHOT)
+ #elif defined(FULL_EDITION)
 	#define EDITION_ " [Full]"
 	#define _EDITION EDITION_
  #else
diff --git a/printf.c b/printf.c
index 9c0bd1f0..db2f4af7 100644
--- a/printf.c
+++ b/printf.c
@@ -101,7 +101,7 @@
 #include 
 #include 
 
-//#include "printf.h"
+#include "printf.h"
 
 #define HAVE_UNSIGNED_LONG_LONG_INT
 #define HAVE_STDINT_H
@@ -801,10 +801,9 @@ int vsprintf(char *buf, const char *fmt, va_list args)
 int sprintf(char *buffer, const char *fmt, ...)
 {//__attribute__ ((format (printf, 2, 3)))
 	va_list args;
-	int i;
 
 	va_start(args, fmt);
-	i = vsprintf(buffer, fmt,args);
+	int i = vsprintf(buffer, fmt,args);
 	va_end(args);
 	return i;
 }
@@ -812,13 +811,26 @@ int sprintf(char *buffer, const char *fmt, ...)
 int snprintf(char *buffer, size_t len, const char *fmt, ...)
 {
 	va_list args;
-	int i;
 
 	va_start(args, fmt);
-	i = vsnprintf(buffer, len, fmt, args);
+	int i = vsnprintf(buffer, len, fmt, args);
 	va_end(args);
 	return i;
 }
+
+static char strfmt_buf[0x200];
+
+char *strfmt(const char *fmt, ...)
+{
+	va_list args;
+
+	va_start(args, fmt);
+	vsnprintf(strfmt_buf, sizeof(strfmt_buf), fmt, args);
+	va_end(args);
+
+	return strfmt_buf;
+}
+
 /*
 #define PRINTF_MAX	128
 
diff --git a/printf.h b/printf.h
index 38fd4703..e1ce1a0e 100644
--- a/printf.h
+++ b/printf.h
@@ -24,8 +24,8 @@
 
 //int vsprintf(char *buf, const char *fmt, va_list args);
 //int vsnprintf(char *str, size_t size, const char *format, va_list args);
-int sprintf(char *buffer, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
-int snprintf(char *buffer, size_t len, const char *fmt, ...);
+//int sprintf(char *buffer, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
+//int snprintf(char *buffer, size_t len, const char *fmt, ...);
+char *strfmt(const char *fmt, ...);
 //int printf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
 #endif
-