From 3f52a6aa50b98adb46bcb4129638145eed022b31 Mon Sep 17 00:00:00 2001 From: Peter Tissen Date: Mon, 10 Feb 2014 02:43:24 +0100 Subject: [PATCH] prevent overflow becaus wxStrings aren't \0 terminated anymore --- rpcs3.sln | 19 ------------------- rpcs3/Emu/FS/vfsLocalFile.cpp | 6 +++--- rpcs3/Emu/System.cpp | 2 +- rpcs3/Gui/ConLog.cpp | 6 +++--- rpcs3/Gui/GameViewer.cpp | 2 +- rpcs3/Gui/MainFrame.cpp | 4 ++-- rpcs3/Loader/ELF64.cpp | 2 +- rpcs3/Loader/PSF.h | 2 +- 8 files changed, 12 insertions(+), 31 deletions(-) diff --git a/rpcs3.sln b/rpcs3.sln index 4194495473..65d6266b30 100644 --- a/rpcs3.sln +++ b/rpcs3.sln @@ -105,8 +105,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ribbon", "wxWidgets\build\m EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stc", "wxWidgets\build\msw\wx_vc10_stc.vcxproj", "{23E1C437-A951-5943-8639-A17F3CF2E606}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "webview", "wxWidgets\build\msw\wx_vc10_webview.vcxproj", "{A8E8442A-078A-5FC5-B495-8D71BA77EE6E}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wxscintilla", "wxWidgets\build\msw\wx_vc10_wxscintilla.vcxproj", "{74827EBD-93DC-5110-BA95-3F2AB029B6B0}" EndProject Global @@ -473,22 +471,6 @@ Global {23E1C437-A951-5943-8639-A17F3CF2E606}.Release|Win32.Build.0 = Release|Win32 {23E1C437-A951-5943-8639-A17F3CF2E606}.Release|x64.ActiveCfg = Release|x64 {23E1C437-A951-5943-8639-A17F3CF2E606}.Release|x64.Build.0 = Release|x64 - {A8E8442A-078A-5FC5-B495-8D71BA77EE6E}.Debug|Win32.ActiveCfg = Debug|Win32 - {A8E8442A-078A-5FC5-B495-8D71BA77EE6E}.Debug|Win32.Build.0 = Debug|Win32 - {A8E8442A-078A-5FC5-B495-8D71BA77EE6E}.Debug|x64.ActiveCfg = Debug|x64 - {A8E8442A-078A-5FC5-B495-8D71BA77EE6E}.Debug|x64.Build.0 = Debug|x64 - {A8E8442A-078A-5FC5-B495-8D71BA77EE6E}.DLL Debug|Win32.ActiveCfg = DLL Debug|Win32 - {A8E8442A-078A-5FC5-B495-8D71BA77EE6E}.DLL Debug|Win32.Build.0 = DLL Debug|Win32 - {A8E8442A-078A-5FC5-B495-8D71BA77EE6E}.DLL Debug|x64.ActiveCfg = DLL Debug|x64 - {A8E8442A-078A-5FC5-B495-8D71BA77EE6E}.DLL Debug|x64.Build.0 = DLL Debug|x64 - {A8E8442A-078A-5FC5-B495-8D71BA77EE6E}.DLL Release|Win32.ActiveCfg = DLL Release|Win32 - {A8E8442A-078A-5FC5-B495-8D71BA77EE6E}.DLL Release|Win32.Build.0 = DLL Release|Win32 - {A8E8442A-078A-5FC5-B495-8D71BA77EE6E}.DLL Release|x64.ActiveCfg = DLL Release|x64 - {A8E8442A-078A-5FC5-B495-8D71BA77EE6E}.DLL Release|x64.Build.0 = DLL Release|x64 - {A8E8442A-078A-5FC5-B495-8D71BA77EE6E}.Release|Win32.ActiveCfg = Release|Win32 - {A8E8442A-078A-5FC5-B495-8D71BA77EE6E}.Release|Win32.Build.0 = Release|Win32 - {A8E8442A-078A-5FC5-B495-8D71BA77EE6E}.Release|x64.ActiveCfg = Release|x64 - {A8E8442A-078A-5FC5-B495-8D71BA77EE6E}.Release|x64.Build.0 = Release|x64 {74827EBD-93DC-5110-BA95-3F2AB029B6B0}.Debug|Win32.ActiveCfg = Debug|Win32 {74827EBD-93DC-5110-BA95-3F2AB029B6B0}.Debug|Win32.Build.0 = Debug|Win32 {74827EBD-93DC-5110-BA95-3F2AB029B6B0}.Debug|x64.ActiveCfg = Debug|x64 @@ -531,7 +513,6 @@ Global {8BECCA95-C7D7-CFF8-FDB1-4950E9F8E8E6} = {5812E712-6213-4372-B095-9EB9BAA1F2DF} {87B42A9C-3F5C-53D7-9017-2B1CAE39457D} = {5812E712-6213-4372-B095-9EB9BAA1F2DF} {23E1C437-A951-5943-8639-A17F3CF2E606} = {5812E712-6213-4372-B095-9EB9BAA1F2DF} - {A8E8442A-078A-5FC5-B495-8D71BA77EE6E} = {5812E712-6213-4372-B095-9EB9BAA1F2DF} {74827EBD-93DC-5110-BA95-3F2AB029B6B0} = {5812E712-6213-4372-B095-9EB9BAA1F2DF} EndGlobalSection EndGlobal diff --git a/rpcs3/Emu/FS/vfsLocalFile.cpp b/rpcs3/Emu/FS/vfsLocalFile.cpp index 06d9a1d3ba..b431c82a4f 100644 --- a/rpcs3/Emu/FS/vfsLocalFile.cpp +++ b/rpcs3/Emu/FS/vfsLocalFile.cpp @@ -54,12 +54,12 @@ bool vfsLocalFile::Open(const wxString& path, vfsOpenMode mode) bool vfsLocalFile::Create(const wxString& path) { ConLog.Warning("vfsLocalFile::Create('%s')", path.c_str()); - for(uint p=1; path[p] != '\0'; p++) + for(uint p=1; p < path.Len() && path[p] != '\0' ; p++) { - for(; path[p] != '\0'; p++) + for(; p < path.Len() && path[p] != '\0'; p++) if(path[p] == '\\') break; - if(path[p] == '\0') + if(p == path.Len() || path[p] == '\0') break; const wxString& dir = path(0, p); diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 46f41a9f9a..69095f95bd 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -188,7 +188,7 @@ void Emulator::Load() { if(!wxFileExists(m_path)) return; - if(IsSelf(m_path.ToStdString())) + if(IsSelf((const char *)m_path.mb_str())) { std::string self_path = m_path; std::string elf_path = wxFileName(m_path).GetPath().c_str(); diff --git a/rpcs3/Gui/ConLog.cpp b/rpcs3/Gui/ConLog.cpp index ebc7cb016f..91c2520696 100644 --- a/rpcs3/Gui/ConLog.cpp +++ b/rpcs3/Gui/ConLog.cpp @@ -187,7 +187,7 @@ void LogWriter::Error(const wxString fmt, ...) va_end(list); - WriteToLog("E", frmt.ToStdString(), "Red"); + WriteToLog("E", (const char *)frmt.mb_str(), "Red"); } void LogWriter::Warning(const wxString fmt, ...) @@ -199,7 +199,7 @@ void LogWriter::Warning(const wxString fmt, ...) va_end(list); - WriteToLog("W", frmt.ToStdString(), "Yellow"); + WriteToLog("W", (const char *)frmt.mb_str(), "Yellow"); } void LogWriter::Success(const wxString fmt, ...) @@ -211,7 +211,7 @@ void LogWriter::Success(const wxString fmt, ...) va_end(list); - WriteToLog("S", frmt.ToStdString(), "Green"); + WriteToLog("S", (const char *)frmt.mb_str(), "Green"); } void LogWriter::SkipLn() diff --git a/rpcs3/Gui/GameViewer.cpp b/rpcs3/Gui/GameViewer.cpp index 6e8d46d6a4..4c9c0b9ed8 100644 --- a/rpcs3/Gui/GameViewer.cpp +++ b/rpcs3/Gui/GameViewer.cpp @@ -91,7 +91,7 @@ void GameViewer::DClick(wxListEvent& event) const wxString& path = m_path + m_game_data[i].root; Emu.Stop(); - if(!Emu.BootGame(path.ToStdString())) + if(!Emu.BootGame((const char *)path.mb_str())) { ConLog.Error("Boot error: elf not found! [%s]", path.mb_str()); return; diff --git a/rpcs3/Gui/MainFrame.cpp b/rpcs3/Gui/MainFrame.cpp index a41aeed74d..41cdbc8c76 100644 --- a/rpcs3/Gui/MainFrame.cpp +++ b/rpcs3/Gui/MainFrame.cpp @@ -192,7 +192,7 @@ void MainFrame::BootGame(wxCommandEvent& WXUNUSED(event)) Emu.Stop(); - if(Emu.BootGame(ctrl.GetPath().ToStdString())) + if(Emu.BootGame((const char *)ctrl.GetPath().mb_str())) { ConLog.Success("Game: boot done."); } @@ -250,7 +250,7 @@ void MainFrame::InstallPkg(wxCommandEvent& WXUNUSED(event)) //Refresh game list m_game_viewer->Refresh(); - if(Emu.BootGame(pkgDir.ToStdString())) + if(Emu.BootGame((const char*)pkgDir.mb_str())) { ConLog.Success("Game: boot done."); } diff --git a/rpcs3/Loader/ELF64.cpp b/rpcs3/Loader/ELF64.cpp index 6af0b0db2a..b140033c9d 100644 --- a/rpcs3/Loader/ELF64.cpp +++ b/rpcs3/Loader/ELF64.cpp @@ -336,7 +336,7 @@ bool ELF64Loader::LoadPhdrData(u64 offset) stub.s_text = re(stub.s_text); const wxString& module_name = Memory.ReadString(stub.s_modulename); - Module* module = GetModuleByName(module_name.ToStdString()); + Module* module = GetModuleByName((const char*)module_name.mb_str()); if(module) { //module->SetLoaded(); diff --git a/rpcs3/Loader/PSF.h b/rpcs3/Loader/PSF.h index b8eca706cc..9598c993a2 100644 --- a/rpcs3/Loader/PSF.h +++ b/rpcs3/Loader/PSF.h @@ -37,7 +37,7 @@ struct PsfEntry return FormatString(); case 0x0404: - return wxString::Format("0x%x", FormatInteger()).ToStdString(); + return wxString::Format("0x%x", FormatInteger()).mb_str(); } }