Merge pull request from GHSA-cfcv-789h-3pg3

GHSL-2023-112: check if the current pointer and the next one are less than the end
pull/14086/head
Don HO 2023-09-01 17:50:08 +02:00 committed by GitHub
commit 4b66d80b2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -152,7 +152,7 @@ size_t Utf8_16_Read::convert(char* buf, size_t len)
case uni16LE_NoBOM:
case uni16BE:
case uni16LE: {
size_t newSize = len + len / 2 + 1;
size_t newSize = (len + len % 2) + (len + len % 2) / 2;
if (m_nAllocatedBufSize != newSize)
{

View File

@ -53,7 +53,9 @@ public:
bool get(utf8 *c);
void operator++();
eState getState() { return m_eState; };
operator bool() { return (m_pRead < m_pEnd) || (m_out1st != m_outLst); };
// Utf8_16::read always consumes two bytes,
// thus the bool operator checks if m_pRead is less than m_pEnd by two bytes.
operator bool() { return (m_pRead + 1 < m_pEnd) || (m_out1st != m_outLst); };
protected:
void read();