mirror of
https://github.com/libretro/ppsspp.git
synced 2025-01-21 08:14:48 +00:00
Switch strncpy to truncate_cpy in a bunch of places.
This commit is contained in:
parent
083f7ff280
commit
21fe73c8e7
@ -219,7 +219,7 @@ void CPUInfo::Detect()
|
||||
strcpy(brand_string, "Unknown");
|
||||
num_cores = 1;
|
||||
#endif
|
||||
strncpy(cpu_string, brand_string, sizeof(cpu_string));
|
||||
truncate_cpy(cpu_string, brand_string);
|
||||
// Hardcode this for now
|
||||
bSwp = true;
|
||||
bHalf = true;
|
||||
@ -237,8 +237,8 @@ void CPUInfo::Detect()
|
||||
bFP = false;
|
||||
bASIMD = false;
|
||||
#else // PPSSPP_PLATFORM(LINUX)
|
||||
strncpy(cpu_string, GetCPUString().c_str(), sizeof(cpu_string));
|
||||
strncpy(brand_string, GetCPUBrandString().c_str(), sizeof(brand_string));
|
||||
truncate_cpy(cpu_string, GetCPUString().c_str());
|
||||
truncate_cpy(brand_string, GetCPUBrandString().c_str());
|
||||
|
||||
bSwp = CheckCPUFeature("swp");
|
||||
bHalf = CheckCPUFeature("half");
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "MemoryUtil.h"
|
||||
#include "MemArena.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
@ -49,7 +50,7 @@ static int ashmem_create_region(const char *name, size_t size) {
|
||||
int ret;
|
||||
if (name) {
|
||||
char buf[ASHMEM_NAME_LEN];
|
||||
strncpy(buf, name, sizeof(buf));
|
||||
truncate_cpy(buf, name);
|
||||
ret = ioctl(fd, ASHMEM_SET_NAME, buf);
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "zlib.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Core/MemMap.h"
|
||||
#include "Core/Debugger/SymbolMap.h"
|
||||
|
||||
@ -427,8 +428,7 @@ void SymbolMap::AddModule(const char *name, u32 address, u32 size) {
|
||||
}
|
||||
|
||||
ModuleEntry mod;
|
||||
strncpy(mod.name, name, ARRAY_SIZE(mod.name));
|
||||
mod.name[ARRAY_SIZE(mod.name) - 1] = '\0';
|
||||
truncate_cpy(mod.name, name);
|
||||
mod.start = address;
|
||||
mod.size = size;
|
||||
mod.index = (int)modules.size() + 1;
|
||||
@ -772,8 +772,7 @@ void SymbolMap::AddLabel(const char* name, u32 address, int moduleIndex) {
|
||||
LabelEntry label;
|
||||
label.addr = relAddress;
|
||||
label.module = moduleIndex;
|
||||
strncpy(label.name, name, 128);
|
||||
label.name[127] = 0;
|
||||
truncate_cpy(label.name, name);
|
||||
|
||||
labels[symbolKey] = label;
|
||||
if (IsModuleActive(moduleIndex)) {
|
||||
@ -791,7 +790,7 @@ void SymbolMap::SetLabelName(const char* name, u32 address) {
|
||||
auto symbolKey = std::make_pair(labelInfo->second.module, labelInfo->second.addr);
|
||||
auto label = labels.find(symbolKey);
|
||||
if (label != labels.end()) {
|
||||
strncpy(label->second.name, name, 128);
|
||||
truncate_cpy(label->second.name, name);
|
||||
label->second.name[127] = 0;
|
||||
|
||||
// Refresh the active item if it exists.
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "i18n/i18n.h"
|
||||
|
||||
#include "Common/ChunkFile.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Core/CoreTiming.h"
|
||||
#include "Core/HLE/sceCtrl.h"
|
||||
#include "Core/Util/PPGeDraw.h"
|
||||
@ -198,7 +199,7 @@ void PSPDialog::DisplayButtons(int flags, const char *caption)
|
||||
char safeCaption[65] = {0};
|
||||
if (caption != NULL && *caption != '\0') {
|
||||
useCaption = true;
|
||||
strncpy(safeCaption, caption, 64);
|
||||
truncate_cpy(safeCaption, caption);
|
||||
}
|
||||
|
||||
I18NCategory *di = GetI18NCategory("Dialog");
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "Core/MemMapHelpers.h"
|
||||
#include "Core/Reporting.h"
|
||||
#include "Common/ChunkFile.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "i18n/i18n.h"
|
||||
#include "util/text/utf8.h"
|
||||
|
||||
@ -130,7 +131,7 @@ int PSPMsgDialog::Init(unsigned int paramAddr) {
|
||||
if (flag & DS_ERRORMSG) {
|
||||
snprintf(msgText, 512, "Error code: %08x", messageDialog.errorNum);
|
||||
} else {
|
||||
strncpy(msgText, messageDialog.string, 512);
|
||||
truncate_cpy(msgText, messageDialog.string);
|
||||
}
|
||||
|
||||
ChangeStatusInit(MSG_INIT_DELAY_US);
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "i18n/i18n.h"
|
||||
#include "base/logging.h"
|
||||
#include "Common/ChunkFile.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Core/Config.h"
|
||||
#include "Core/Host.h"
|
||||
#include "Core/Reporting.h"
|
||||
@ -55,8 +56,7 @@ namespace
|
||||
void SetStringFromSFO(ParamSFOData &sfoFile, const char *name, char *str, int strLength)
|
||||
{
|
||||
std::string value = sfoFile.GetValueString(name);
|
||||
strncpy(str, value.c_str(), strLength - 1);
|
||||
str[strLength - 1] = 0;
|
||||
truncate_cpy(str, value.c_str());
|
||||
}
|
||||
|
||||
bool ReadPSPFile(std::string filename, u8 **data, s64 dataSize, s64 *readSize)
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "thread/threadutil.h"
|
||||
#include "profiler/profiler.h"
|
||||
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Core/Core.h"
|
||||
#include "Core/Config.h"
|
||||
#include "Core/Debugger/Breakpoints.h"
|
||||
@ -2184,8 +2185,7 @@ static u32 sceIoDread(int id, u32 dirent_addr) {
|
||||
PSPFileInfo &info = dir->listing[dir->index];
|
||||
__IoGetStat(&entry->d_stat, info);
|
||||
|
||||
strncpy(entry->d_name, info.name.c_str(), 256);
|
||||
entry->d_name[255] = '\0';
|
||||
truncate_cpy(entry->d_name, info.name.c_str());
|
||||
|
||||
bool isFAT = false;
|
||||
IFileSystem *sys = pspFileSystem.GetSystemFromFilename(dir->name);
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "Core/MIPS/MIPSAsm.h"
|
||||
#include "Core/MIPS/MIPSAnalyst.h"
|
||||
#include "Core/Config.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Windows/Debugger/CtrlDisAsmView.h"
|
||||
#include "Windows/Debugger/Debugger_MemoryDlg.h"
|
||||
#include "Windows/Debugger/DebuggerShared.h"
|
||||
@ -970,7 +971,7 @@ void CtrlDisAsmView::onMouseUp(WPARAM wParam, LPARAM lParam, int button)
|
||||
{
|
||||
char name[256];
|
||||
std::string newname;
|
||||
strncpy_s(name, g_symbolMap->GetLabelString(funcBegin).c_str(),_TRUNCATE);
|
||||
truncate_cpy(name, g_symbolMap->GetLabelString(funcBegin).c_str());
|
||||
if (InputBox_GetString(MainWindow::GetHInstance(), MainWindow::GetHWND(), L"New function name", name, newname)) {
|
||||
g_symbolMap->SetLabelName(newname.c_str(),funcBegin);
|
||||
u32 funcSize = g_symbolMap->GetFunctionSize(curAddress);
|
||||
|
@ -143,9 +143,9 @@ void CheckGLExtensions() {
|
||||
// Start by assuming we're at 2.0.
|
||||
int parsed[2] = {2, 0};
|
||||
{ // Grab the version and attempt to parse.
|
||||
char buffer[64] = { 0 };
|
||||
char buffer[128] = { 0 };
|
||||
if (versionStr) {
|
||||
strncpy(buffer, versionStr, 63);
|
||||
strncpy(buffer, versionStr, sizeof(buffer) - 1);
|
||||
}
|
||||
|
||||
int len = (int)strlen(buffer);
|
||||
@ -159,7 +159,7 @@ void CheckGLExtensions() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (beforeDot && buffer[i] == '.' && lastDigit) {
|
||||
if (beforeDot && buffer[i] == '.' && lastDigit) {
|
||||
parsed[0] = lastDigit;
|
||||
beforeDot = false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user