Added size check to injected files instead of attempting to load them all into memory

This commit is contained in:
Leon Styhre 2024-05-11 16:01:38 +02:00
parent e30c2b5fa8
commit 684b7e2e6a

View file

@ -1591,8 +1591,11 @@ void FileData::launchGame()
std::string arguments; std::string arguments;
std::ifstream injectFileStream; std::ifstream injectFileStream;
injectFileStream.open(injectFile); injectFileStream.open(injectFile);
for (std::string line; getline(injectFileStream, line);) for (std::string line; getline(injectFileStream, line);) {
arguments += line; arguments += line;
if (arguments.size() > 4096)
break;
}
injectFileStream.close(); injectFileStream.close();
if (arguments.empty()) { if (arguments.empty()) {
@ -1602,8 +1605,7 @@ void FileData::launchGame()
} }
else if (arguments.size() > 4096) { else if (arguments.size() > 4096) {
LOG(LogWarning) << "FileData::launchGame(): Injection file exceeding maximum " LOG(LogWarning) << "FileData::launchGame(): Injection file exceeding maximum "
"allowed size of " "allowed size of 4096 bytes, skipping \""
"4096 bytes, skipping \""
<< injectFile << "\""; << injectFile << "\"";
} }
else { else {