From 11ac93cfdb9f4f25eee2ba60b947f992ab40ec54 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Thu, 31 Mar 2016 09:45:20 -0700 Subject: Fix CData parsing in CFDE_XMLSyntaxParser. This CL splits the handling of CData sections out to an individual phase of the parser. This fixes the issue with the CData parser getting confused by < characters inside the data section. BUG=pdfium:90 Review URL: https://codereview.chromium.org/1842633004 --- xfa/fgas/crt/fgas_stream.cpp | 6 ++++-- xfa/fgas/crt/fgas_system.cpp | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'xfa/fgas/crt') diff --git a/xfa/fgas/crt/fgas_stream.cpp b/xfa/fgas/crt/fgas_stream.cpp index 8ab2f9fd37..94468e23da 100644 --- a/xfa/fgas/crt/fgas_stream.cpp +++ b/xfa/fgas/crt/fgas_stream.cpp @@ -870,8 +870,9 @@ int32_t CFX_BufferStreamImp::ReadString(FX_WCHAR* pStr, } const FX_WCHAR* pSrc = (const FX_WCHAR*)(FX_CHAR*)(m_pData + m_iPosition); int32_t iCount = 0; - while (*pSrc != L'\0' && iCount < iLen) { - *pStr++ = *pSrc++, iCount++; + while (*pSrc && iCount < iLen) { + *pStr++ = *pSrc++; + iCount++; } m_iPosition += iCount * 2; bEOS = (*pSrc == L'\0') || (m_iPosition >= m_iLength); @@ -1345,6 +1346,7 @@ int32_t CFX_Stream::ReadString(FX_WCHAR* pStr, } return iLen; } + int32_t CFX_Stream::WriteData(const uint8_t* pBuffer, int32_t iBufferSize) { FXSYS_assert(pBuffer != NULL && iBufferSize > 0); if (m_pStreamImp == NULL) { diff --git a/xfa/fgas/crt/fgas_system.cpp b/xfa/fgas/crt/fgas_system.cpp index df1a9d044a..7ba2d924ca 100644 --- a/xfa/fgas/crt/fgas_system.cpp +++ b/xfa/fgas/crt/fgas_system.cpp @@ -31,7 +31,8 @@ inline int32_t FX_tolower(int32_t ch) { int32_t FX_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t count) { FXSYS_assert(s1 != NULL && s2 != NULL && count > 0); - FX_WCHAR wch1 = 0, wch2 = 0; + FX_WCHAR wch1 = 0; + FX_WCHAR wch2 = 0; while (count-- > 0) { wch1 = (FX_WCHAR)FX_tolower(*s1++); wch2 = (FX_WCHAR)FX_tolower(*s2++); -- cgit v1.2.3