Re: [xml] Change from 1.8.2 to 1.8.7 causes major failure

Date view Thread view Subject view Author view

From: Daniel Veillard (Daniel.Veillard@w3.org)
Date: Wed Apr 05 2000 - 07:30:49 EDT


On Wed, Apr 05, 2000 at 02:24:16PM +1000, Byron Ellacott wrote:
>
>
> I recently updated my libxml from 1.8.2 to 1.8.7; this immediately broke
> the application I am writing.
>
> The application reads a number of XML files, converting them to an
> internal tree structure. I do this by glob()ing over the files and
> reading each in turn.
>
> Now, the first problem is the files have some header details. This means
> I can't use xmlParseFile()[0]. So I skip the header, and read the
> remainder of the file into a memory buffer, and call xmlParseMemory().
> This used to work. Now, it only works for the first file, and fails for
> the second and subsequent files. It's not an error in the files, since
> removing or renaming the first file causes the second to be read and
> parsed, and the third and subsequent to fail.

  Ok I think I know the problem:
    - The xml parser need a 0 terminated string
    - previous versions used to modify the buffer passed by the
      application to make sure it was 0 terminated
    - this was crashing apps where the input was read-only memory
    - now there is a check internally verifying this and aborting
      if buffer[size] != 0

  So basically the answer is:
    add an instruction buffer[size] = 0 before calling xmlParseMemory()

> Now, to top it all off, I cannot find any way short of debugging through
> xmlParseMemory to find out what is causing the parse to fail. There are
> no error messages printed, which is probably a good thing, but there is no
> way (that I could find) to discover what went wrong[1].
>
> Does anyone know why this would happen, if there's a way to find errors
> that I've just missed, or what I can do short of installing an older
> version?

  Well if debugging the code under gdb (or other) the check was only
2 level down xmlParseMemory(). Being silent in that case is IMHO a feature
since it's a fix which need to be done only once by the developper
and users should not be bothered by this.

> --
> bje
>
> [0] Why isn't there an xmlParseStream(FILE *input) method? I'm sure I'm
> not the only one who would find it useful.

  This could be implemented in less than 10 lines of code using
existing interface, there is actually such code in parser.c / xmllint.c
in parseAndPrintFile(char *filename)

> [1] xmlParseMemory(buffer, buffer_size, &error_code) perhaps.

  It's an API access error and I would rather not mix API errors
and XML parsing error reporting. The current state is that the
former don't get really reported.

Daniel

-- 
Daniel.Veillard@w3.org | W3C, INRIA Rhone-Alpes  | Today's Bookmarks :
Tel : +33 476 615 257  | 655, avenue de l'Europe | Linux XML libxml WWW
Fax : +33 476 615 207  | 38330 Montbonnot FRANCE | Gnome rpm2html rpmfind
 http://www.w3.org/People/all#veillard%40w3.org  | RPM badminton Kaffe
----
Message from the list xml@xmlsoft.org
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@xmlsoft.org


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Wed Aug 02 2000 - 12:30:10 EDT