Closed jktjkt closed 7 years ago
Yes, we were considering usage of a third-party XML parser. However, because YANG modeled XML data (and YIN format of the schema) has several limitation from the XML point of view (no mixed content, no PI, no CDATA sections), we have decided to write internal parser that can be tighten to the YANG data needs. The data structures can be smaller than in most XML parsers and as a bonus we avoid a dependency on external library.
TL;DR: calling something like
memcmp(input, "<![CDATA[", 9)
fails if input contains less than 9 characters.lyxml_parse_elem
callsmemcmp
in itsprocess
loop in a way which makes it easy to read behind the end of the user input. Here's what ASAN says:I tried to read through the project history for a rationale for coming up with a hand-crafted XML parser. I understand that libxml2 was rejected due to the worries about its resource usage. I wonder if you gave consideration to other existing XML parsers, especially those which are streaming in nature? Expat, for example?