Re: [xml] Crash when parsing bad HTML



[ Putting xml gnome org back in copy, Daniel ]

On Thu, Aug 23, 2007 at 09:35:07AM -0400, Pierre Belzile wrote:

   I have a trace now with the library not optimized. It's triggering the
   code for handling processing instructions.
   It  crashes  because  ctxt->myDoc  is  still empty (SAX2.c, line 2546,
   ctxt->myDoc->children)
   Here is the non-optimized trace:
   #0  0x0000002a96e89723 in xmlSAX2ProcessingInstruction__internal_alias
   (ctx=0x28f8b00, target=0x28fbe09 "PRE", data=0x0)
       at SAX2.c:2546
   #1     0x0000002a96dd4a7f    in    htmlParsePI   (ctxt=0x28f8b00)   at
   HTMLparser.c:2926
   #2    0x0000002a96dd7313   in   htmlParseContent  (ctxt=0x28f8b00)  at
   HTMLparser.c:3894
   #3      0x0000002a96dd77a3     in     htmlParseElement__internal_alias
   (ctxt=0x28f8b00) at HTMLparser.c:4059
   #4    0x0000002a96dd732f   in   htmlParseContent  (ctxt=0x28f8b00)  at
   HTMLparser.c:3901
   #5      0x0000002a96dd77a3     in     htmlParseElement__internal_alias
   (ctxt=0x28f8b00) at HTMLparser.c:4059
   #6    0x0000002a96dd732f   in   htmlParseContent  (ctxt=0x28f8b00)  at
   HTMLparser.c:3901
   #7      0x0000002a96dd7c2a     in    htmlParseDocument__internal_alias
   (ctxt=0x28f8b00) at HTMLparser.c:4166
   I  don't  need  this  processing  so  I made the processingInstruction
   handler NULL and it now works.

  Ahhhh You didn't tell you were using SAX specific callbacks.
Well if you use an incoherent set of callbacks then sure you can crash
your application. xmlSAX2ProcessingInstruction() and others libxml2
own SAX2 callbacks expects to work all together. Cherry picking one
and not the other can lead to crash, definitely and that's not a libxml2
bug, it's a bug in the way the application was constructed with libxml2
blocks.

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]