mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
fix: correct sscanf %x signedness and avoid a substr copy
libSceSysmodule/Export.cpp parsed /proc/self/maps device major/minor numbers into signed int with a %x format, which is undefined behaviour per the C standard even though it happened to work on this target; switched to unsigned int to match the format specifier. NidPatcherUtils.hpp's StripNidPostfix built a truncated copy with substr(0, n) where the prefix is already the string itself; resize(n) does the same truncation without the extra allocation and copy. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -44,7 +44,7 @@ inline std::string StripNidPostfix(const std::string& name) {
|
||||
std::string result = name;
|
||||
if (result.size() >= kNidPostfixLen &&
|
||||
result.compare(result.size() - kNidPostfixLen, kNidPostfixLen, kNidPostfix) == 0) {
|
||||
result = result.substr(0u, result.size() - kNidPostfixLen);
|
||||
result.resize(result.size() - kNidPostfixLen);
|
||||
}
|
||||
const auto disambigPos = result.rfind(kNidDisambigMarker);
|
||||
if (disambigPos != std::string::npos) {
|
||||
@@ -54,7 +54,7 @@ inline std::string StripNidPostfix(const std::string& name) {
|
||||
[](unsigned char c) { return std::isdigit(c) != 0; }
|
||||
);
|
||||
if (allDigits && suffixStart < result.size())
|
||||
result = result.substr(0u, disambigPos);
|
||||
result.resize(disambigPos);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@ bool fillModuleInfoForUnwind(std::uint64_t addr, ModuleInfoForUnwind* info) {
|
||||
std::uint64_t end = 0;
|
||||
char perms[8] = {};
|
||||
std::uint64_t offset = 0;
|
||||
int devMajor = 0;
|
||||
int devMinor = 0;
|
||||
unsigned int devMajor = 0;
|
||||
unsigned int devMinor = 0;
|
||||
std::uint64_t inode = 0;
|
||||
char path[4096] = {};
|
||||
int parsed = std::sscanf(
|
||||
|
||||
Reference in New Issue
Block a user