From 62313d93480f2631ea82664c790fd01875b850a6 Mon Sep 17 00:00:00 2001 From: Bhargava Shastry Date: Fri, 27 Dec 2019 17:50:49 +0100 Subject: xml proto converter: Fix ossfuzz issue 19507 (no return value). (#3167) --- projects/xerces-c/xmlProtoConverter.cpp | 42 ++++++++++++++++++++++++++++++++- projects/xerces-c/xmlProtoConverter.h | 5 ++++ 2 files changed, 46 insertions(+), 1 deletion(-) (limited to 'projects/xerces-c') diff --git a/projects/xerces-c/xmlProtoConverter.cpp b/projects/xerces-c/xmlProtoConverter.cpp index b2caf67a2..f8a47dee2 100644 --- a/projects/xerces-c/xmlProtoConverter.cpp +++ b/projects/xerces-c/xmlProtoConverter.cpp @@ -56,6 +56,9 @@ void ProtoConverter::visit(Prolog const& _x) void ProtoConverter::visit(KeyValue const& _x) { + if (!KeyValue::XmlNamespace_IsValid(_x.type())) + return; + switch (_x.type()) { case KeyValue::ATTRIBUTES: @@ -127,6 +130,9 @@ void ProtoConverter::visit(Content const& _x) void ProtoConverter::visit(ElementDecl const& _x) { + if (!ElementDecl::ContentSpec_IsValid(_x.spec())) + return; + m_output << "\n"; @@ -715,4 +755,4 @@ string ProtoConverter::protoToString(XmlDocument const& _x) { visit(_x); return m_output.str(); -} \ No newline at end of file +} diff --git a/projects/xerces-c/xmlProtoConverter.h b/projects/xerces-c/xmlProtoConverter.h index a6333f1b3..501dde36c 100644 --- a/projects/xerces-c/xmlProtoConverter.h +++ b/projects/xerces-c/xmlProtoConverter.h @@ -89,6 +89,11 @@ private: void visit(XmlDocument const&); + template + bool isValid(T const& messageType) { + return T::Type_IsValid(messageType.type()); + } + std::string removeNonAscii(std::string const&); std::string getUri(Element_Id _x); std::string getPredefined(Element_Id _x, std::string const&); -- cgit v1.2.3