[xml] No stat, no catalog.

Hello everyone.

Again we have an issue regarding HAVE_STAT. Somewhere in catalog.c, in the
function xmlLoadCatalog, we can find the following lines:

    #ifdef HAVE_STAT
        if (stat(filename, &info) < 0)

Later in the same function we can see the following:

    content = xmlMalloc(info.st_size + 10);

If HAVE_STAT is not defined, the local variable 'info' remains
uninitialised. This leads to a problem, because the actual value of what we
pass into xmlMalloc is unpredictable in this case. Unfortunately, the proper
operation of the code that follows depends on successful execution of the
stat function.

If there is no alternative portable way to discover the size of the file
'filename', I would suggest to either make the catalog feature dependent on
the availability of the function stat, or let the xmlLoadCatalog function
fail if the function stat is not available. The way things are, the
successful execution of the xmlLoadCatalog function depends on nothing but
luck, if HAVE_STAT is undefined.

I actually discovered this because HAVE_STAT was undefined in catalog.c
while compiling libxml2 on Win32 using MCVS. Since MSVC and its libraries do
provide this function, I suggest a patch for include/win32config.h which
ensures that HAVE_STAT is defined everywhere. Here it is:

*** gnome-xml/include/win32config.h     2001/08/03 12:06:34     1.12
--- gnome-xml/include/win32config.h     2001/09/30 23:29:27
*** 110,115 ****
--- 110,116 ----

  #define HAVE_SYS_STAT_H
  #define HAVE__STAT
+ #define HAVE_STAT

  #include <libxml/xmlwin32version.h>

What do you think?

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