More review changes
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user