diff --git a/Core/Debugger/SymbolMap.cpp b/Core/Debugger/SymbolMap.cpp index aa4006bba7..c95982e44b 100644 --- a/Core/Debugger/SymbolMap.cpp +++ b/Core/Debugger/SymbolMap.cpp @@ -403,7 +403,7 @@ u32 SymbolMap::GetNextSymbolAddress(u32 address, SymbolType symmask) { std::string SymbolMap::GetDescription(unsigned int address) { std::lock_guard guard(lock_); - const char* labelName = NULL; + const char *labelName = nullptr; u32 funcStart = GetFunctionStart(address); if (funcStart != INVALID_ADDRESS) { @@ -414,11 +414,11 @@ std::string SymbolMap::GetDescription(unsigned int address) { labelName = GetLabelName(dataStart); } - if (labelName != NULL) + if (labelName) return labelName; - char descriptionTemp[256]; - sprintf(descriptionTemp, "(%08x)", address); + char descriptionTemp[32]; + snprintf(descriptionTemp, sizeof(descriptionTemp), "(%08x)", address); return descriptionTemp; } @@ -435,7 +435,7 @@ std::vector SymbolMap::GetAllSymbols(SymbolType symmask) { entry.address = it->first; entry.size = GetFunctionSize(entry.address); const char* name = GetLabelName(entry.address); - if (name != NULL) + if (name) entry.name = name; result.push_back(entry); } @@ -448,7 +448,7 @@ std::vector SymbolMap::GetAllSymbols(SymbolType symmask) { entry.address = it->first; entry.size = GetDataSize(entry.address); const char* name = GetLabelName(entry.address); - if (name != NULL) + if (name) entry.name = name; result.push_back(entry); } diff --git a/Core/HLE/sceKernelEventFlag.cpp b/Core/HLE/sceKernelEventFlag.cpp index 89a9226380..a9d4dddea0 100644 --- a/Core/HLE/sceKernelEventFlag.cpp +++ b/Core/HLE/sceKernelEventFlag.cpp @@ -58,7 +58,7 @@ public: const char *GetTypeName() override { return GetStaticTypeName(); } static const char *GetStaticTypeName() { return "EventFlag"; } void GetQuickInfo(char *ptr, int size) override { - sprintf(ptr, "init=%08x cur=%08x numwait=%i", + snprintf(ptr, size, "init=%08x cur=%08x numwait=%i", nef.initPattern, nef.currentPattern, nef.numWaitThreads); diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index 115ac2ac53..c6812d403d 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -275,10 +275,8 @@ public: const char *GetName() override { return nm.name; } const char *GetTypeName() override { return GetStaticTypeName(); } static const char *GetStaticTypeName() { return "Module"; } - void GetQuickInfo(char *ptr, int size) override - { - // ignore size - sprintf(ptr, "%sname=%s gp=%08x entry=%08x", + void GetQuickInfo(char *ptr, int size) override { + snprintf(ptr, size, "%sname=%s gp=%08x entry=%08x", isFake ? "faked " : "", nm.name, nm.gp_value, @@ -394,7 +392,7 @@ public: // Add the symbol to the symbol map for debugging. char temp[256]; - sprintf(temp,"zz_%s", GetFuncName(func.moduleName, func.nid)); + snprintf(temp, sizeof(temp), "zz_%s", GetFuncName(func.moduleName, func.nid)); g_symbolMap->AddFunction(temp,func.stubAddr,8); // Keep track and actually hook it up if possible. diff --git a/Core/HLE/sceKernelThread.cpp b/Core/HLE/sceKernelThread.cpp index 91066511c1..7a791c34e6 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -140,7 +140,7 @@ public: static const char *GetStaticTypeName() { return "CallBack"; } void GetQuickInfo(char *ptr, int size) override { - sprintf(ptr, "thread=%i, argument= %08x", + snprintf(ptr, size, "thread=%i, argument= %08x", //hackAddress, nc.threadId, nc.commonArgument); @@ -378,7 +378,7 @@ public: const char *GetTypeName() override { return GetStaticTypeName(); } static const char *GetStaticTypeName() { return "Thread"; } void GetQuickInfo(char *ptr, int size) override { - sprintf(ptr, "pc= %08x sp= %08x %s %s %s %s %s %s (wt=%i wid=%i wv= %08x )", + snprintf(ptr, size, "pc= %08x sp= %08x %s %s %s %s %s %s (wt=%i wid=%i wv= %08x )", context.pc, context.r[MIPS_REG_SP], (nt.status & THREADSTATUS_RUNNING) ? "RUN" : "", (nt.status & THREADSTATUS_READY) ? "READY" : "", @@ -1699,7 +1699,7 @@ static void __ReportThreadQueueEmpty() { idleThread0->GetQuickInfo(idleDescription0, sizeof(idleDescription0)); idleStatus0 = idleThread0->nt.status; } else { - sprintf(idleDescription0, "DELETED"); + truncate_cpy(idleDescription0, "DELETED"); } char idleDescription1[256]; @@ -1708,7 +1708,7 @@ static void __ReportThreadQueueEmpty() { idleThread1->GetQuickInfo(idleDescription1, sizeof(idleDescription1)); idleStatus1 = idleThread1->nt.status; } else { - sprintf(idleDescription1, "DELETED"); + truncate_cpy(idleDescription1, "DELETED"); } ERROR_LOG_REPORT_ONCE(threadqueueempty, Log::sceKernel, "Failed to reschedule: out of threads on queue (%d, %d)", idleStatus0, idleStatus1);