Fix heap-buffer overflow in PLY parser

pull/5312/head^2
Alexandre Avenel 2023-11-04 10:28:19 +01:00 committed by Kim Kulling
parent bfe8745b90
commit e4e2c63e0c
2 changed files with 3 additions and 2 deletions

View File

@ -425,7 +425,8 @@ bool PLY::DOM::ParseHeader(IOStreamBuffer<char> &streamBuffer, std::vector<char>
break;
} else {
// ignore unknown header elements
streamBuffer.getNextLine(buffer);
if (!streamBuffer.getNextLine(buffer))
return false;
}
}

View File

@ -287,7 +287,7 @@ static AI_FORCE_INLINE bool isEndOfCache(size_t pos, size_t cacheSize) {
template <class T>
AI_FORCE_INLINE bool IOStreamBuffer<T>::getNextLine(std::vector<T> &buffer) {
buffer.resize(m_cacheSize);
if (isEndOfCache(m_cachePos, m_cacheSize) || 0 == m_filePos) {
if (m_cachePos >= m_cacheSize || 0 == m_filePos) {
if (!readNextBlock()) {
return false;
}