[xmlsec] Re: libxmlsec problem, dl.c

Aleksey Sanin aleksey at aleksey.com
Wed Oct 27 08:33:35 PDT 2004


Good catch! Fixed.

Thanks!
Aleksey

Checking in dl.c;
/cvs/gnome/xmlsec/src/dl.c,v  <--  dl.c
new revision: 1.10; previous revision: 1.9
done

Daniel Vogelheim wrote:
> Dear Aleksey,
> 
> I have encountered a problem with libxmlsec, and I believe you are the 
> proper addressee for making sure a fix gets into the libxmlsec 
> distribution. If not, please advise on whom else to contact.
> 
> 
> The problem is in file src/dl.c, in one of the initialization functions. 
> In there, pointers to allocator/deallocator methods are initialized, but 
> only after they have in been used in code called from the initialization 
> routine itself. The result is memory being allocated through the default 
> memory allocator, but later on this memory is freed using the 
> non-matching, custom deallocator.
> 
> Please find below:
> 1) a more detailed description of the problem, and
> 2) a patch for src/dl.c, for integration into libxmlsec
> 
> If you see any problems with the fix, I would appreciate some feedback 
> on the details. Thank you very much.
> 
> Sincerely,
> Daniel Vogelheim
> 
> 
> Problem description:
> ---------------------
> Investigation revealed a problem in src/dl.c, function 
> xmlSecCryptoDLInit(): This method calls two init functions, 
> xmlSecPtrListInitialize(..) and xmlsec_lt_dlinit(), and at the end 
> initializes two function pointers used for memory 
> allocation/deallocation by libxmlsec, xmlsec_lt_dlmalloc and 
> xmlsec_lt_dlfree. The problem is that xmlsec_lt_dlinit allocates memory 
> using libxmlsec_lt_dlmalloc (e.g. in lt_dlloader_add(..)) *before* 
> assigning the allocator function pointer. This results in memory being 
> allocated using the default (system) allocator and being freed through 
> our (non-system) allocator, which doesn't work. Moving the 
> xmlsec_lt_dlmalloc/.._dlfree initialization to the top of the function 
> solves the problem. Would this fix be acceptable?
> --------------------
> 
> Patch file:
> ------------------------
> [...\xmlsec1-1.2.4\src]diff -u dl.c~ dl.c
> --- dl.c~       Wed Oct 29 15:57:20 2003
> +++ dl.c        Tue Oct 26 12:12:26 2004
> @@ -329,6 +329,10 @@
> xmlSecCryptoDLInit(void) {
>    int ret;
> 
> +    /* use xmlMalloc/xmlFree */
> +    xmlsec_lt_dlmalloc = xmlSecCryptoDLMalloc;
> +    xmlsec_lt_dlfree   = xmlSecCryptoDLFree;
> +
>    ret = xmlSecPtrListInitialize(&gXmlSecCryptoDLLibraries, 
> xmlSecCryptoDLLibr
> ariesListGetKlass());
>    if(ret < 0) {
>       xmlSecError(XMLSEC_ERRORS_HERE,
> @@ -350,9 +354,6 @@
>    }
>    /* TODO: LTDL_SET_PRELOADED_SYMBOLS(); */
> 
> -    /* use xmlMalloc/xmlFree */
> -    xmlsec_lt_dlmalloc = xmlSecCryptoDLMalloc;
> -    xmlsec_lt_dlfree   = xmlSecCryptoDLFree;
>    return(0);
> }
> ----------------------------
> 
> 



More information about the xmlsec mailing list