More review changes

This commit is contained in:
jpirnay
2026-03-08 11:27:52 +01:00
parent 2010b33e5d
commit 42a01446ef
3 changed files with 31 additions and 16 deletions
+8 -2
View File
@@ -41,7 +41,10 @@ constexpr uint32_t MAX_STRING_LENGTH = 4096;
static bool readString(std::istream& is, std::string& s) {
uint32_t len;
readPod(is, len);
if (len > MAX_STRING_LENGTH) return false;
if (len > MAX_STRING_LENGTH) {
is.seekg(len, std::ios::cur); // skip payload to keep stream aligned
return false;
}
s.resize(len);
is.read(&s[0], len);
return true;
@@ -50,7 +53,10 @@ static bool readString(std::istream& is, std::string& s) {
static bool readString(FsFile& file, std::string& s) {
uint32_t len;
readPod(file, len);
if (len > MAX_STRING_LENGTH) return false;
if (len > MAX_STRING_LENGTH) {
file.seekCur(len); // skip payload to keep file position aligned
return false;
}
s.resize(len);
file.read(reinterpret_cast<uint8_t*>(&s[0]), len);
return true;