GNOME Bugzilla – Bug 699896
Parsing of empty stream is passing without error
Last modified: 2013-05-09 10:48:49 UTC
In _XML_DeSerializeFromCustomStream(tXmlDoc *const pDoc,tParseContext * const pStream,tXmlNode ** ppNode) when the stream is empty, the condition in line 357 fails as nBytes is 0 and xmlSaxParseFromCustomStream returns without any error. But then isn't empty string("") an invalid xml and shouldn't we throw an error? For instance parsing of a string with only a space (" ") fails.
thinkpad:~/XML -> cat /dev/null > 699896.xml thinkpad:~/XML -> xmllint 699896.xml 699896.xml:1: parser error : Document is empty ^ 699896.xml:1: parser error : Start tag expected, '<' not found ^ thinkpad:~/XML -> xmllint --stream 699896.xml 699896.xml:1: parser error : Extra content at the end of the document ^ 699896.xml : failed to parse thinkpad:~/XML -> xmllint --memory 699896.xml thinkpad:~/XML -> but that was the result of an mmap failure not reported by xmllint, after fixing it: thinkpad:~/XML -> xmllint --memory 699896.xml mmap failure for file 699896.xml thinkpad:~/XML -> echo $? 4 thinkpad:~/XML -> I have no way to guess what _XML_DeSerializeFromCustomStream does, it is not in libxml2 code, what entry point are you using ? Can you reproduce this with xmllint or provide a standalone C file reproducing the problem ? Daniel
I guess it needs to be handled in custom parser stream. The problem over here is that the custom function should handle the return value. When the condition in Line 357(libxml2.cpp) if((nBytes = (*pStream->readFunc )(pStream->pCustomStreamer ,(tChar*)buffer, sizeof(buffer)))) fails,xmlParseChunk function is not called. I am not able to reproduce it from xmllint. Considering the fact that anyway the return value is -1, this can be handled by calling function. Can I close this defect as not a bug ?
I guess it needs to be handled in custom function. The problem over here is that the custom function should handle the return value. When the condition in Line 357(libxml2.cpp) if((nBytes = (*pStream->readFunc )(pStream->pCustomStreamer ,(tChar*)buffer, sizeof(buffer)))) fails,xmlParseChunk function is not called. I am not able to reproduce it from xmllint. Considering the fact that anyway the return value is -1, this can be handled by calling function. Can I close this defect as not a bug ?
The problem is not in libxml2, so CLOSED NOTGNOME sounds right ! Daniel