From b0803a4bc6a505acd3662e917b754c99cbe2e8e5 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Sun, 13 Sep 2015 23:39:35 +0100 Subject: [PATCH] pcsx2:debugger: Fix potential buffer overrun CID 146914 (#1 of 1): Copy into fixed size buffer (STRING_OVERFLOW) The overflow can be triggered using the Debugger's Rename Function feature. --- pcsx2/DebugTools/SymbolMap.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pcsx2/DebugTools/SymbolMap.cpp b/pcsx2/DebugTools/SymbolMap.cpp index faf31a2689..2c08b95d63 100644 --- a/pcsx2/DebugTools/SymbolMap.cpp +++ b/pcsx2/DebugTools/SymbolMap.cpp @@ -576,8 +576,8 @@ void SymbolMap::SetLabelName(const char* name, u32 address, bool updateImmediate auto symbolKey = std::make_pair(labelInfo->second.module, labelInfo->second.addr); auto label = labels.find(symbolKey); if (label != labels.end()) { - strcpy(label->second.name,name); - label->second.name[127] = 0; + strncpy(label->second.name, name, ARRAY_SIZE(label->second.name)); + label->second.name[ARRAY_SIZE(label->second.name) - 1] = 0; // Allow the caller to skip this as it causes extreme startup slowdown // when this gets called for every function identified by the function replacement code.