Re: [xml] libxml-2.6.22 SEGV on Solaris



On Wed, Oct 26, 2005 at 03:28:32AM -0500, Albert Chin wrote:
"testapi -q" is generating a SEGV on Solaris. 2.6.22 was built with
the Sun C compiler (though I duplicated the SEGV with gcc-3.4.3). From
the coredump:
$ dbx .libs/testapi core
program terminated by signal SEGV (no mapping at the fault address)
0xfecaea90: strlen+0x0050:      ld       [%o2], %o1
Current function is __xmlRaiseError
  497           XML_GET_VAR_STR(msg, str);
(dbx) where                                                                  
  [1] strlen(0x0, 0xfffffaf0, 0x0, 0xffbff858, 0x0, 0x2b), at 0xfecaea90 
  [2] _ndoprnt(0xff337956, 0xffbffa00, 0xffbff199, 0x0, 0x0, 0x0), at 0xfed135e4 
  [3] vsnprintf(0x1ebf28, 0x96, 0xff337934, 0xffbff9fc, 0x7ffffc00, 0xfed6c950), at 0xfed15c64 
[...]

  Solaris libc dies on *printf( "%s", NULL) ... classic portability bug

So, when no == 7, filename = NULL. Should xmlNewInputFromFile() return
NULL if its filename argument is NULL like it does if its ctx argument
is NULL?

  It should return NULL from __xmlParserInputBufferCreateFilename()
but buf == NULL will be detected first and __xmlLoaderErr() will be called.
Calling the error handler because you tried to load a NULL filename is
sensible, that should not be changed. What should is that the error
message printing should not segfault which is the real error. Turning
around the real bug by not calling it is not the right way to handle
this. Instead of calling blindly 
  __xmlLoaderErr(ctxt, "failed to load external entity \"%s\"\n",
                       (const char *) filename);

filename == NULL must be tested first to make a separate __xmlLoaderErr 
call.

        if (filename == NULL)
            __xmlLoaderErr(ctxt,
                           "failed to load external entity: NULL filename \n",
                           NULL);
        else
            __xmlLoaderErr(ctxt, "failed to load external entity \"%s\"\n",
                           (const char *) filename);

I commited this in CVS, could you double check it fixes the problem and that
no other similar error shows up ?

  thanks !

Daniel

-- 
Daniel Veillard      | Red Hat http://redhat.com/
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]