Ensure raw tagnames are safe exiting internalEntityParser
Some checks failed
Ensure that GNU Autotools and CMake build systems agree / Ensure that GNU Autotools and CMake build systems agree (-DCMAKE_TOOLCHAIN_FILE=cmake/mingw-toolchain.cmake, --host=i686-w64-mingw32, ubuntu-20.04) (push) Has been cancelled
Ensure that GNU Autotools and CMake build systems agree / Ensure that GNU Autotools and CMake build systems agree (<nil>, <nil>, macos-10.15) (push) Has been cancelled
Ensure that GNU Autotools and CMake build systems agree / Ensure that GNU Autotools and CMake build systems agree (<nil>, <nil>, ubuntu-20.04) (push) Has been cancelled
Ensure realistic minimum CMake version requirement / Ensure realistic minimum CMake version requirement (push) Has been cancelled
Collect test coverage / Collect test coverage (push) Has been cancelled
Run Cppcheck (from macOS Homebrew) / Run Cppcheck (push) Has been cancelled
Check expat_config.h.{in,cmake} for regressions / Check expat_config.h.{in,cmake} for regressions (push) Has been cancelled
Run Linux Travis CI tasks / Perform checks (CC=clang CXX=clang++ LD=clang++ QA_SANITIZER=address CMAKE_ARGS=-DEXPAT_ATTR_INFO=ON, qa-sh) (push) Has been cancelled
Run Linux Travis CI tasks / Perform checks (CC=clang CXX=clang++ LD=clang++ QA_SANITIZER=address CMAKE_ARGS=-DEXPAT_CONTEXT_BYTES=OFF, qa-sh) (push) Has been cancelled
Run Linux Travis CI tasks / Perform checks (CC=clang CXX=clang++ LD=clang++ QA_SANITIZER=address CMAKE_ARGS=-DEXPAT_DTD=OFF, qa-sh) (push) Has been cancelled
Run Linux Travis CI tasks / Perform checks (CC=clang CXX=clang++ LD=clang++ QA_SANITIZER=address CMAKE_ARGS=-DEXPAT_LARGE_SIZE=ON, qa-sh) (push) Has been cancelled
Run Linux Travis CI tasks / Perform checks (CC=clang CXX=clang++ LD=clang++ QA_SANITIZER=address CMAKE_ARGS=-DEXPAT_MIN_SIZE=ON, qa-sh) (push) Has been cancelled
Run Linux Travis CI tasks / Perform checks (CC=clang CXX=clang++ LD=clang++ QA_SANITIZER=address CMAKE_ARGS=-DEXPAT_NS=OFF, qa-sh) (push) Has been cancelled
Run Linux Travis CI tasks / Perform checks (CC=clang CXX=clang++ LD=clang++ QA_SANITIZER=address, qa-sh) (push) Has been cancelled
Run Linux Travis CI tasks / Perform checks (CC=clang CXX=clang++ LD=clang++ QA_SANITIZER=memory, qa-sh) (push) Has been cancelled
Run Linux Travis CI tasks / Perform checks (CC=clang CXX=clang++ LD=clang++ QA_SANITIZER=undefined, qa-sh) (push) Has been cancelled
Run Linux Travis CI tasks / Perform checks (CC=gcc CXX=g++ LD=ld QA_PROCESSOR=gcov CMAKE_ARGS="-D_EXPAT_M32=ON -DEXPAT_ATTR_INFO=ON", qa-sh) (push) Has been cancelled
Run Linux Travis CI tasks / Perform checks (CC=gcc CXX=g++ LD=ld QA_PROCESSOR=gcov CMAKE_ARGS=-D_EXPAT_M32=ON, qa-sh) (push) Has been cancelled
Run Linux Travis CI tasks / Perform checks (CC=gcc CXX=g++ LD=ld QA_PROCESSOR=gcov, qa-sh) (push) Has been cancelled
Run Linux Travis CI tasks / Perform checks (CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++ LD=i686-w64-mingw32-ld QA_PROCESSOR=gcov CMAKE_ARGS="-DCMAKE_SYSTEM_NAME=Windows -DWIN32=ON -DMINGW=ON -DEXPAT_ATTR_INFO=ON -DEXPAT_CHAR_TYPE=wchar_t", qa-sh) (push) Has been cancelled
Run Linux Travis CI tasks / Perform checks (CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++ LD=i686-w64-mingw32-ld QA_PROCESSOR=gcov CMAKE_ARGS="-DCMAKE_SYSTEM_NAME=Windows -DWIN32=ON -DMINGW=ON -DEXPAT_ATTR_INFO=ON", qa-sh) (push) Has been cancelled
Run Linux Travis CI tasks / Perform checks (CMAKE_ARGS="-DEXPAT_ATTR_INFO=ON -DEXPAT_BUILD_FUZZERS=ON -DCMAKE_C_FLAGS=-fsanitize=address -DCMAKE_CXX_FLAGS=-fsanitize=address -DCMAKE_EXE_LINKER_FLAGS=-fsanitize=address -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++", cmake-… (push) Has been cancelled
Run Linux Travis CI tasks / Perform checks (clang-format) (push) Has been cancelled
Run Linux Travis CI tasks / Perform checks (cmake-oos) (push) Has been cancelled
Run Linux Travis CI tasks / Perform checks (distcheck) (push) Has been cancelled
Run macOS Travis CI tasks / Perform checks (CC=clang CXX=clang++ LD=clang++ QA_SANITIZER=address, qa-sh) (push) Has been cancelled
Run macOS Travis CI tasks / Perform checks (cmake-oos) (push) Has been cancelled
Run macOS Travis CI tasks / Perform checks (distcheck) (push) Has been cancelled
Ensure well-formed and valid XML / Ensure well-formed and valid XML (push) Has been cancelled

It is possible to concoct a situation in which parsing is
suspended while substituting in an internal entity, so that
XML_ResumeParser directly uses internalEntityProcessor as
its processor.  If the subsequent parse includes some unclosed
tags, this will return without calling storeRawNames to ensure
that the raw versions of the tag names are stored in memory other
than the parse buffer itself.  If the parse buffer is then changed
or reallocated (for example if processing a file line by line),
badness will ensue.

This patch ensures storeRawNames is always called when needed
after calling doContent.  The earlier call do doContent does
not need the same protection; it only deals with entity
substitution, which cannot leave unbalanced tags, and in any
case the raw names will be pointing into the stored entity
value not the parse buffer.
This commit is contained in:
Rhodri James 2022-08-17 18:26:18 +01:00 committed by Vadim Zeitlin
parent 52f86db3e4
commit 23b7f47ef6

View File

@ -5879,10 +5879,15 @@ internalEntityProcessor(XML_Parser parser, const char *s, const char *end,
{
parser->m_processor = contentProcessor;
/* see externalEntityContentProcessor vs contentProcessor */
return doContent(parser, parser->m_parentParser ? 1 : 0, parser->m_encoding,
s, end, nextPtr,
(XML_Bool)! parser->m_parsingStatus.finalBuffer,
XML_ACCOUNT_DIRECT);
result = doContent(parser, parser->m_parentParser ? 1 : 0,
parser->m_encoding, s, end, nextPtr,
(XML_Bool)! parser->m_parsingStatus.finalBuffer,
XML_ACCOUNT_DIRECT);
if (result == XML_ERROR_NONE) {
if (! storeRawNames(parser))
return XML_ERROR_NO_MEMORY;
}
return result;
}
}