After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 699896 - Parsing of empty stream is passing without error
Parsing of empty stream is passing without error
Status: RESOLVED NOTGNOME
Product: libxml2
Classification: Platform
Component: general
git master
Other All
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2013-05-08 05:20 UTC by Harish
Modified: 2013-05-09 10:48 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Harish 2013-05-08 05:20:21 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.
Comment 1 Daniel Veillard 2013-05-08 05:45:22 UTC
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
Comment 2 Harish 2013-05-09 10:37:37 UTC
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 ?
Comment 3 Harish 2013-05-09 10:38:24 UTC
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 ?
Comment 4 Daniel Veillard 2013-05-09 10:48:49 UTC
The problem is not in libxml2, so CLOSED NOTGNOME sounds right !

Daniel