Fixed some stack buffer overruns introduced by the new commandline options features in r294. They only happened when using one of the plugin override options (-spu or -gs, for example).

git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@306 a6443dda-0b58-4228-96e9-037be469359c
This commit is contained in:
Jake.Stine 2008-11-06 06:28:10 +00:00 committed by Gregory Hainaut
parent 6930ed533c
commit 56004a1e8b
11 changed files with 80 additions and 92 deletions

View File

@ -1,23 +0,0 @@
// svnrev_unknown.h --> svnrev.h
//
// This file acts as a placebo for people who do not have TortoiseSVN installed.
// It provides "empty" revision information to the Pcsx2 Playground projects in
// the absence of real revisions derived from the repository being built.
//
// This file does not affect application/dll builds in any significant manner,
// other than the lack of automatic revision tags inserted into the app (which
// is very convenient but hardly necessary).
//
// See svn_template.h for more information on how the process of revision
// templating works.
//
// If you would like to enable automatic revisin tagging, TortoiseSVN can be
// downloaded from http://tortoisesvn.tigris.org
#define SVN_REV_UNKNOWN
// The following defines are included so that code will still compile even if it
// doesn't check for the SVN_REV_UNKNOWN define.
#define SVN_REV 0
#define SVN_MODS ""

View File

@ -131,16 +131,15 @@ static int mg_BIToffset(u8 *buffer);
FILE *_cdvdOpenMechaVer() {
char *ptr;
int i;
char file[256];
char Bios[256];
char file[g_MaxPath];
char Bios[g_MaxPath];
FILE* fd;
// get the name of the bios file
strcpy(Bios, Config.BiosDir);
strcat(Bios, Config.Bios);
CombinePaths( Bios, Config.BiosDir, Config.Bios );
// use the bios filename to get the name of the mecha ver file
sprintf(file, "%s", Bios);
strcpy(file, Bios);
ptr = file; i = (int)strlen(file);
while (i > 0) { if (ptr[i] == '.') break; i--; }
ptr[i+1] = '\0';
@ -175,16 +174,15 @@ s32 cdvdGetMechaVer(u8* ver)
FILE *_cdvdOpenNVM() {
char *ptr;
int i;
char Bios[256];
char file[256];
char Bios[g_MaxPath];
char file[g_MaxPath];
FILE* fd;
// get the name of the bios file
strcpy(Bios, Config.BiosDir);
strcat(Bios, Config.Bios);
CombinePaths( Bios, Config.BiosDir, Config.Bios );
// use the bios filename to get the name of the nvm file
sprintf(file, "%s", Bios);
strcpy( file, Bios );
ptr = file; i = (int)strlen(file);
while (i > 0) { if (ptr[i] == '.') break; i--; }
ptr[i+1] = '\0';
@ -364,7 +362,7 @@ s32 cdvdWriteConfig(const u8* config)
void cdvdReadKey(u8 arg0, u16 arg1, u32 arg2, u8* key) {
char str[256];
char str[g_MaxPath];
int numbers;
int letters;
unsigned int key_0_3;
@ -571,7 +569,7 @@ s32 cdvdGetDiskType() {
cdvd.Type = CDVDgetDiskType();
if (cdvd.Type == CDVD_TYPE_PS2CD && needReset == 1) {
char str[256];
char str[g_MaxPath];
if (GetPS2ElfName(str) == 1) {
cdvd.Type = CDVD_TYPE_PSCD;
} // ENDIF- Does the SYSTEM.CNF file only say "BOOT="? PS1 CD then.
@ -783,7 +781,7 @@ int cdvdInterrupt() {
void cdvdNewDiskCB() {
cdvd.Type = CDVDgetDiskType();
if(cdvd.Type == CDVD_TYPE_PS2CD) {
char str[256];
char str[g_MaxPath];
if(GetPS2ElfName(str) == 1) {
cdvd.Type = CDVD_TYPE_PSCD;
} // ENDIF- Does the SYSTEM.CNF file only say "BOOT="? PS1 CD then.

View File

@ -3038,14 +3038,13 @@ void memWrite128(u32 mem, u64 *value) {
void loadBiosRom(char *ext, u8 *dest) {
struct stat buf;
char Bios1[256];
char Bios[256];
char Bios1[g_MaxPath];
char Bios[g_MaxPath];
FILE *fp;
char *ptr;
int i;
strcpy(Bios, Config.BiosDir);
strcat(Bios, Config.Bios);
CombinePaths( Bios, Config.BiosDir, Config.Bios );
sprintf(Bios1, "%s.%s", Bios, ext);
if (stat(Bios1, &buf) != -1) {
@ -3082,7 +3081,7 @@ void loadBiosRom(char *ext, u8 *dest) {
void memReset() {
struct stat buf;
char Bios[256];
char Bios[g_MaxPath];
FILE *fp;
#ifdef PCSX2_VIRTUAL_MEM
@ -3094,8 +3093,7 @@ void memReset() {
memset(psS, 0, 0x00004000);
#endif
strcpy(Bios, Config.BiosDir);
strcat(Bios, Config.Bios);
CombinePaths( Bios, Config.BiosDir, Config.Bios );
if (stat(Bios, &buf) == -1) {
SysMessage(_("Unable to load bios: '%s', PCSX2 can't run without that"), Bios);

View File

@ -886,15 +886,30 @@ char* mystrlwr( char* string )
return string;
}
static void GetSaveStateFilename( char* dest )
{
char elfcrcText[72];
sprintf( elfcrcText, "%8.8X.%3.3d", ElfCRC, StatesC );
CombinePaths( dest, SSTATES_DIR, elfcrcText );
}
static void GetGSStateFilename( char* dest )
{
char gsText[72];
sprintf( gsText, "/%8.8X.%d.gs", ElfCRC, StatesC);
CombinePaths( dest, SSTATES_DIR, gsText );
}
void ProcessFKeys(int fkey, int shift)
{
char Text[256];
int ret;
char Text[g_MaxPath];
assert(fkey >= 1 && fkey <= 12 );
switch(fkey) {
case 1:
sprintf(Text, SSTATES_DIR "/%8.8X.%3.3d", ElfCRC, StatesC);
GetSaveStateFilename(Text);
ret = SaveState(Text);
break;
case 2:
@ -904,12 +919,12 @@ void ProcessFKeys(int fkey, int shift)
StatesC = (StatesC+1)%NUM_STATES;
SysPrintf("*PCSX2*: Selected State %ld\n", StatesC);
if( GSchangeSaveState != NULL ) {
sprintf(Text, SSTATES_DIR "/%8.8X.%3.3d", ElfCRC, StatesC);
GetSaveStateFilename(Text);
GSchangeSaveState(StatesC, Text);
}
break;
case 3:
sprintf (Text, SSTATES_DIR "/%8.8X.%3.3d", ElfCRC, StatesC);
case 3:
GetSaveStateFilename(Text);
ret = LoadState(Text);
break;
@ -999,17 +1014,19 @@ void ProcessFKeys(int fkey, int shift)
else {
if( strgametitle[0] != 0 ) {
// only take the first two words
char name[255], temptitle[255], *tok;
sprintf(temptitle, "%s", strgametitle);
char name[256], *tok;
char gsText[256];
tok = strtok(strgametitle, " ");
sprintf(name, "%s_", mystrlwr(tok));
tok = strtok(NULL, " ");
if( tok != NULL ) strcat(name, tok);
sprintf(Text, SSTATES_DIR "/%s.%d.gs", name, StatesC);
sprintf( gsText, "%s.%d.gs", name, StatesC);
CombinePaths( Text, SSTATES_DIR, gsText );
}
else
sprintf(Text, SSTATES_DIR "/%8.8X.%d.gs", ElfCRC, StatesC);
GetGSStateFilename( Text );
SaveGSState(Text);
}

View File

@ -439,10 +439,10 @@ void cpuBranchTest()
// Signal for an immediate branch test! This is important! The IOP must
// be able to act on the state the EE has given it before executing any
// additional code. Dothing this actually fixes some games that used to crash
// additional code. Doing this actually fixes some games that used to crash
// when trying to boot them through the BIOS.
psxBranchTest();
//psxBranchTest();
EEsCycle += cpuRegs.cycle - EEoCycle;
EEoCycle = cpuRegs.cycle;

View File

@ -52,7 +52,7 @@ BOOL OnConfigureDialog(HWND hW) {
HWND hWC_USB=GetDlgItem(hW,IDC_LISTUSB);
HWND hWC_FW=GetDlgItem(hW,IDC_LISTFW);
HWND hWC_BIOS=GetDlgItem(hW,IDC_LISTBIOS);
char tmpStr[256];
char tmpStr[g_MaxPath];
char *lp;
int i;
@ -62,7 +62,7 @@ BOOL OnConfigureDialog(HWND hW) {
do {
if (Find==INVALID_HANDLE_VALUE) break;
sprintf(tmpStr,"%s%s", Config.PluginsDir, FindData.cFileName);
CombinePaths( tmpStr, Config.PluginsDir, FindData.cFileName );
Lib = LoadLibrary(tmpStr);
if (Lib == NULL) { SysPrintf("%s: %d\n", tmpStr, GetLastError()); continue; }
@ -329,7 +329,7 @@ static void TestPlugin( HWND hW, int confs, const char* name )
int (*conf)();
int ret = 0;
char * pDLL = GetComboSel(hW, confs);
char file[256];
char file[g_MaxPath];
if (pDLL== NULL) return;
CombinePaths( file, Config.PluginsDir, pDLL );

View File

@ -172,23 +172,23 @@ void ResetMenuSlots() {
}
void UpdateMenuSlots() {
char str[256];
char str[g_MaxPath];
int i;
for (i=0; i<5; i++) {
sprintf (str, "sstates\\%8.8X.%3.3d", ElfCRC, i);
sprintf_s (str, g_MaxPath, "sstates\\%8.8X.%3.3d", ElfCRC, i);
Slots[i] = CheckState(str);
}
}
void States_Load(int num) {
char Text[256];
char Text[g_MaxPath];
int ret;
efile = 0;
RunExecute(0);
sprintf (Text, "sstates\\%8.8X.%3.3d", ElfCRC, num);
sprintf_s(Text, g_MaxPath, "sstates\\%8.8X.%3.3d", ElfCRC, num);
ret = LoadState(Text);
if (ret == 0)
sprintf (Text, _("*PCSX2*: Loaded State %d"), num+1);
@ -217,9 +217,9 @@ void States_Save(int num) {
void OnStates_LoadOther() {
OPENFILENAME ofn;
char szFileName[256];
char szFileTitle[256];
char szFilter[256];
char szFileName[g_MaxPath];
char szFileTitle[g_MaxPath];
char szFilter[g_MaxPath];
memset(&szFileName, 0, sizeof(szFileName));
memset(&szFileTitle, 0, sizeof(szFileTitle));
@ -234,16 +234,16 @@ void OnStates_LoadOther() {
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 1;
ofn.lpstrFile = szFileName;
ofn.nMaxFile = 256;
ofn.nMaxFile = g_MaxPath;
ofn.lpstrInitialDir = NULL;
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = 256;
ofn.nMaxFileTitle = g_MaxPath;
ofn.lpstrTitle = NULL;
ofn.lpstrDefExt = "EXE";
ofn.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
if (GetOpenFileName ((LPOPENFILENAME)&ofn)) {
char Text[256];
char Text[g_MaxPath];
int ret;
efile = 2;
@ -252,8 +252,8 @@ void OnStates_LoadOther() {
ret = LoadState(szFileName);
if (ret == 0)
sprintf(Text, _("*PCSX2*: Saving State %s"), szFileName);
else sprintf(Text, _("*PCSX2*: Error Saving State %s"), szFileName);
sprintf_s(Text, g_MaxPath, _("*PCSX2*: Saving State %s"), szFileName);
else sprintf_s(Text, g_MaxPath, _("*PCSX2*: Error Saving State %s"), szFileName);
StatusSet(Text);
Cpu->Execute();
@ -270,9 +270,9 @@ const char* g_pRunGSState = NULL;
void OnStates_SaveOther() {
OPENFILENAME ofn;
char szFileName[256];
char szFileTitle[256];
char szFilter[256];
char szFileName[g_MaxPath];
char szFileTitle[g_MaxPath];
char szFilter[g_MaxPath];
memset(&szFileName, 0, sizeof(szFileName));
memset(&szFileTitle, 0, sizeof(szFileTitle));
@ -287,22 +287,22 @@ void OnStates_SaveOther() {
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 1;
ofn.lpstrFile = szFileName;
ofn.nMaxFile = 256;
ofn.nMaxFile = g_MaxPath;
ofn.lpstrInitialDir = NULL;
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = 256;
ofn.nMaxFileTitle = g_MaxPath;
ofn.lpstrTitle = NULL;
ofn.lpstrDefExt = "EXE";
ofn.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
if (GetOpenFileName ((LPOPENFILENAME)&ofn)) {
char Text[256];
char Text[g_MaxPath];
int ret;
ret = SaveState(szFileName);
if (ret == 0)
sprintf(Text, _("*PCSX2*: Loaded State %s"), szFileName);
else sprintf(Text, _("*PCSX2*: Error Loading State %s"), szFileName);
sprintf_s(Text, g_MaxPath, _("*PCSX2*: Loaded State %s"), szFileName);
else sprintf_s(Text, g_MaxPath, _("*PCSX2*: Error Loading State %s"), szFileName);
StatusSet(Text);
RunExecute(1);
@ -1594,8 +1594,8 @@ void CreateMainWindow(int nCmdShow) {
BOOL Open_File_Proc(char * filename) {
OPENFILENAME ofn;
char szFileName[ 256 ];
char szFileTitle[ 256 ];
char szFileName[ g_MaxPath ];
char szFileTitle[ g_MaxPath ];
char * filter = "ELF Files (*.ELF)\0*.ELF\0ALL Files (*.*)\0*.*\0";
memset( &szFileName, 0, sizeof( szFileName ) );
@ -1608,10 +1608,10 @@ BOOL Open_File_Proc(char * filename) {
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 1;
ofn.lpstrFile = szFileName;
ofn.nMaxFile = 256;
ofn.nMaxFile = g_MaxPath;
ofn.lpstrInitialDir = NULL;
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = 256;
ofn.nMaxFileTitle = g_MaxPath;
ofn.lpstrTitle = NULL;
ofn.lpstrDefExt = "ELF";
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
@ -1652,9 +1652,7 @@ BOOL APIENTRY CmdlineProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
GetDlgItemText(hDlg, IDC_CMDLINE, tmp, 256);
ZeroMemory(args, 256);
strcpy(args, tmp);
args[255]=0;
strcpy_s(args, 256, tmp);
EndDialog(hDlg, TRUE);
} else if (LOWORD(wParam) == IDCANCEL) {

View File

@ -149,7 +149,7 @@ BASEBLOCKEX* PSX_GETBLOCKEX(BASEBLOCK* p)
static void iDumpBlock( int startpc, s8 * ptr )
{
FILE *f;
char filename[ 256 ];
char filename[ g_MaxPath ];
#ifdef __LINUX__
char command[256];
#endif
@ -161,7 +161,7 @@ static void iDumpBlock( int startpc, s8 * ptr )
SysPrintf( "dump1 %x:%x, %x\n", startpc, psxpc, psxRegs.cycle );
#ifdef _WIN32
CreateDirectory("dumps", NULL);
sprintf( filename, "dumps\\psxdump%.8X.txt", startpc);
sprintf_s( filename, g_MaxPath, "dumps\\psxdump%.8X.txt", startpc);
#else
mkdir("dumps", 0755);
sprintf( filename, "dumps/psxdump%.8X.txt", startpc);

View File

@ -110,13 +110,13 @@ void recResetVU1( void ) {
static void iDumpBlock()
{
FILE *f;
char filename[ 256 ];
char filename[ g_MaxPath ];
u32 *mem;
u32 i;
#ifdef _WIN32
CreateDirectory("dumps", NULL);
sprintf( filename, "dumps\\vu%.4X.txt", VU1.VI[ REG_TPC ].UL );
sprintf_s( filename, g_MaxPath, "dumps\\vu%.4X.txt", VU1.VI[ REG_TPC ].UL );
#else
mkdir("dumps", 0755);
sprintf( filename, "dumps/vu%.4X.txt", VU1.VI[ REG_TPC ].UL );

View File

@ -521,13 +521,13 @@ u32 SuperVUGetVIAddr(int reg, int read)
void SuperVUDumpBlock(list<VuBaseBlock*>& blocks, int vuindex)
{
FILE *f;
char filename[ 256 ], str[256];
char filename[ g_MaxPath ], str[256];
u32 *mem;
u32 i;
#ifdef _WIN32
CreateDirectory("dumps", NULL);
sprintf( filename, "dumps\\svu%c_%.4X.txt", s_vu?'1':'0', s_pFnHeader->startpc );
sprintf_s( filename, g_MaxPath, "dumps\\svu%c_%.4X.txt", s_vu?'1':'0', s_pFnHeader->startpc );
#else
mkdir("dumps", 0755);
sprintf( filename, "dumps/svu%c_%.4X.txt", s_vu?'1':'0', s_pFnHeader->startpc );

View File

@ -141,7 +141,7 @@ BASEBLOCKEX* PC_GETBLOCKEX(BASEBLOCK* p)
void iDumpBlock( int startpc, s8 * ptr )
{
FILE *f;
char filename[ 256 ];
char filename[ g_MaxPath ];
u32 i, j;
EEINST* pcur;
extern char *disRNameGPR[];
@ -152,7 +152,7 @@ void iDumpBlock( int startpc, s8 * ptr )
SysPrintf( "dump1 %x:%x, %x\n", startpc, pc, cpuRegs.cycle );
#ifdef _WIN32
CreateDirectory("dumps", NULL);
sprintf( filename, "dumps\\dump%.8X.txt", startpc);
sprintf_s( filename, g_MaxPath, "dumps\\dump%.8X.txt", startpc);
#else
mkdir("dumps", 0755);
sprintf( filename, "dumps/dump%.8X.txt", startpc);