[libxslt] 305913 a serious problem in extensions reentrancy
- From: Daniel Veillard <veillard src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libxslt] 305913 a serious problem in extensions reentrancy
- Date: Fri, 14 Aug 2009 07:04:06 +0000 (UTC)
commit b1c52a885d7d2c2b4db9e9cde97456f626093b7d
Author: Daniel Veillard <veillard redhat com>
Date: Fri Aug 14 09:02:16 2009 +0200
305913 a serious problem in extensions reentrancy
* libexslt/exslt.c libxslt/extensions.c libxslt/extensions.h
libxslt/security.c libxslt/transform.c libxslt/xslt.c: extension
support use some global variables, make sure there is a Mutex to
access and modify them
libexslt/exslt.c | 1 +
libxslt/extensions.c | 194 ++++++++++++++++++++++++++++++++++++++++++++------
libxslt/extensions.h | 88 +++++++++++++----------
libxslt/security.c | 5 ++
libxslt/transform.c | 4 +
libxslt/xslt.c | 8 ++
6 files changed, 239 insertions(+), 61 deletions(-)
---
diff --git a/libexslt/exslt.c b/libexslt/exslt.c
index c20ec5d..f29c42b 100644
--- a/libexslt/exslt.c
+++ b/libexslt/exslt.c
@@ -24,6 +24,7 @@ const int exsltLibxmlVersion = LIBXML_VERSION;
*/
void
exsltRegisterAll (void) {
+ xsltInitGlobals();
exsltCommonRegister();
#ifdef EXSLT_CRYPTO_ENABLED
exsltCryptoRegister();
diff --git a/libxslt/extensions.c b/libxslt/extensions.c
index 87eefb4..530516b 100644
--- a/libxslt/extensions.c
+++ b/libxslt/extensions.c
@@ -86,6 +86,7 @@ static xmlHashTablePtr xsltFunctionsHash = NULL;
static xmlHashTablePtr xsltElementsHash = NULL;
static xmlHashTablePtr xsltTopLevelsHash = NULL;
static xmlHashTablePtr xsltModuleHash = NULL;
+static xmlMutexPtr xsltExtMutex = NULL;
/************************************************************************
* *
@@ -312,6 +313,8 @@ typedef void (*exsltRegisterFunction) (void);
* by LIBXSLT_DEFAULT_PLUGINS_PATH() which is determined at
* compile time.
*
+ * Always called with xsltExtMutex lock taken.
+ *
* Returns 0 if successful, -1 in case of error.
*/
@@ -339,10 +342,14 @@ xsltExtModuleRegisterDynamic(const xmlChar * URI)
return (-1);
}
+ xmlMutexLock(xsltExtMutex);
+
/* have we attempted to register this module already? */
if (xmlHashLookup(xsltModuleHash, URI) != NULL) {
+ xmlMutexUnlock(xsltExtMutex);
return (-1);
}
+ xmlMutexUnlock(xsltExtMutex);
/* transform extension namespace into a module name */
protocol = xmlStrstr(URI, BAD_CAST "://");
@@ -429,7 +436,9 @@ xsltExtModuleRegisterDynamic(const xmlChar * URI)
(*regfunc) ();
/* register this module in our hash */
+ xmlMutexLock(xsltExtMutex);
xmlHashAddEntry(xsltModuleHash, URI, (void *) m);
+ xmlMutexUnlock(xsltExtMutex);
} else {
#ifdef WITH_XSLT_DEBUG_EXTENSIONS
@@ -448,7 +457,7 @@ xsltExtModuleRegisterDynamic(const xmlChar * URI)
}
#else
static int
-xsltExtModuleRegisterDynamic(const xmlChar * ATTRIBUTE_UNUSED URI)
+xsltExtModuleRegisterDynamic(const xmlChar * URI ATTRIBUTE_UNUSED)
{
return -1;
}
@@ -575,6 +584,8 @@ int
xsltRegisterExtFunction(xsltTransformContextPtr ctxt, const xmlChar * name,
const xmlChar * URI, xmlXPathFunction function)
{
+ int ret;
+
if ((ctxt == NULL) || (name == NULL) ||
(URI == NULL) || (function == NULL))
return (-1);
@@ -585,8 +596,11 @@ xsltRegisterExtFunction(xsltTransformContextPtr ctxt, const xmlChar * name,
ctxt->extFunctions = xmlHashCreate(10);
if (ctxt->extFunctions == NULL)
return (-1);
- return (xmlHashAddEntry2
- (ctxt->extFunctions, name, URI, XML_CAST_FPTR(function)));
+
+ ret = xmlHashAddEntry2(ctxt->extFunctions, name, URI,
+ XML_CAST_FPTR(function));
+
+ return(ret);
}
/**
@@ -661,7 +675,12 @@ xsltStyleInitializeStylesheetModule(xsltStylesheetPtr style,
return(NULL);
}
+ xmlMutexLock(xsltExtMutex);
+
module = xmlHashLookup(xsltExtensionsHash, URI);
+
+ xmlMutexUnlock(xsltExtMutex);
+
if (module == NULL) {
#ifdef WITH_XSLT_DEBUG_EXTENSIONS
xsltGenericDebug(xsltGenericDebugContext,
@@ -855,7 +874,12 @@ xsltGetExtData(xsltTransformContextPtr ctxt, const xmlChar * URI)
void *extData;
xsltExtModulePtr module;
+ xmlMutexLock(xsltExtMutex);
+
module = xmlHashLookup(xsltExtensionsHash, URI);
+
+ xmlMutexUnlock(xsltExtMutex);
+
if (module == NULL) {
#ifdef WITH_XSLT_DEBUG_EXTENSIONS
xsltGenericDebug(xsltGenericDebugContext,
@@ -1235,18 +1259,27 @@ xsltRegisterExtModuleFull(const xmlChar * URI,
if (xsltExtensionsHash == NULL)
return (-1);
+ xmlMutexLock(xsltExtMutex);
+
module = xmlHashLookup(xsltExtensionsHash, URI);
if (module != NULL) {
if ((module->initFunc == initFunc) &&
(module->shutdownFunc == shutdownFunc))
- return (0);
- return (-1);
+ ret = 0;
+ else
+ ret = -1;
+ goto done;
}
module = xsltNewExtModule(initFunc, shutdownFunc,
styleInitFunc, styleShutdownFunc);
- if (module == NULL)
- return (-1);
+ if (module == NULL) {
+ ret = -1;
+ goto done;
+ }
ret = xmlHashAddEntry(xsltExtensionsHash, URI, (void *) module);
+
+done:
+ xmlMutexUnlock(xsltExtMutex);
return (ret);
}
@@ -1287,9 +1320,13 @@ xsltUnregisterExtModule(const xmlChar * URI)
if (xsltExtensionsHash == NULL)
return (-1);
- ret =
- xmlHashRemoveEntry(xsltExtensionsHash, URI,
- (xmlHashDeallocator) xsltFreeExtModule);
+ xmlMutexLock(xsltExtMutex);
+
+ ret = xmlHashRemoveEntry(xsltExtensionsHash, URI,
+ (xmlHashDeallocator) xsltFreeExtModule);
+
+ xmlMutexUnlock(xsltExtMutex);
+
return (ret);
}
@@ -1304,9 +1341,13 @@ xsltUnregisterAllExtModules(void)
if (xsltExtensionsHash == NULL)
return;
+ xmlMutexLock(xsltExtMutex);
+
xmlHashFree(xsltExtensionsHash,
(xmlHashDeallocator) xsltFreeExtModule);
xsltExtensionsHash = NULL;
+
+ xmlMutexUnlock(xsltExtMutex);
}
/**
@@ -1351,9 +1392,13 @@ xsltRegisterExtModuleFunction(const xmlChar * name, const xmlChar * URI,
if (xsltFunctionsHash == NULL)
return (-1);
+ xmlMutexLock(xsltExtMutex);
+
xmlHashUpdateEntry2(xsltFunctionsHash, name, URI,
XML_CAST_FPTR(function), NULL);
+ xmlMutexUnlock(xsltExtMutex);
+
return (0);
}
@@ -1374,6 +1419,8 @@ xsltExtModuleFunctionLookup(const xmlChar * name, const xmlChar * URI)
if ((xsltFunctionsHash == NULL) || (name == NULL) || (URI == NULL))
return (NULL);
+ xmlMutexLock(xsltExtMutex);
+
XML_CAST_FPTR(ret) = xmlHashLookup2(xsltFunctionsHash, name, URI);
/* if lookup fails, attempt a dynamic load on supported platforms */
@@ -1384,6 +1431,8 @@ xsltExtModuleFunctionLookup(const xmlChar * name, const xmlChar * URI)
}
}
+ xmlMutexUnlock(xsltExtMutex);
+
return ret;
}
@@ -1399,10 +1448,18 @@ xsltExtModuleFunctionLookup(const xmlChar * name, const xmlChar * URI)
int
xsltUnregisterExtModuleFunction(const xmlChar * name, const xmlChar * URI)
{
+ int ret;
+
if ((xsltFunctionsHash == NULL) || (name == NULL) || (URI == NULL))
return (-1);
- return xmlHashRemoveEntry2(xsltFunctionsHash, name, URI, NULL);
+ xmlMutexLock(xsltExtMutex);
+
+ ret = xmlHashRemoveEntry2(xsltFunctionsHash, name, URI, NULL);
+
+ xmlMutexUnlock(xsltExtMutex);
+
+ return(ret);
}
/**
@@ -1413,8 +1470,12 @@ xsltUnregisterExtModuleFunction(const xmlChar * name, const xmlChar * URI)
static void
xsltUnregisterAllExtModuleFunction(void)
{
+ xmlMutexLock(xsltExtMutex);
+
xmlHashFree(xsltFunctionsHash, NULL);
xsltFunctionsHash = NULL;
+
+ xmlMutexUnlock(xsltExtMutex);
}
@@ -1494,8 +1555,13 @@ xsltPreComputeExtModuleElement(xsltStylesheetPtr style, xmlNodePtr inst)
(inst->type != XML_ELEMENT_NODE) || (inst->ns == NULL))
return (NULL);
+ xmlMutexLock(xsltExtMutex);
+
ext = (xsltExtElementPtr)
xmlHashLookup2(xsltElementsHash, inst->name, inst->ns->href);
+
+ xmlMutexUnlock(xsltExtMutex);
+
/*
* EXT TODO: Now what?
*/
@@ -1549,6 +1615,8 @@ xsltRegisterExtModuleElement(const xmlChar * name, const xmlChar * URI,
xsltPreComputeFunction precomp,
xsltTransformFunction transform)
{
+ int ret;
+
xsltExtElementPtr ext;
if ((name == NULL) || (URI == NULL) || (transform == NULL))
@@ -1559,13 +1627,20 @@ xsltRegisterExtModuleElement(const xmlChar * name, const xmlChar * URI,
if (xsltElementsHash == NULL)
return (-1);
+ xmlMutexLock(xsltExtMutex);
+
ext = xsltNewExtElement(precomp, transform);
- if (ext == NULL)
- return (-1);
+ if (ext == NULL) {
+ ret = -1;
+ goto done;
+ }
xmlHashUpdateEntry2(xsltElementsHash, name, URI, (void *) ext,
(xmlHashDeallocator) xsltFreeExtElement);
+done:
+ xmlMutexUnlock(xsltExtMutex);
+
return (0);
}
@@ -1589,12 +1664,21 @@ xsltExtElementLookup(xsltTransformContextPtr ctxt,
if ((name == NULL) || (URI == NULL))
return (NULL);
+ xmlMutexLock(xsltExtMutex);
+
if ((ctxt != NULL) && (ctxt->extElements != NULL)) {
XML_CAST_FPTR(ret) = xmlHashLookup2(ctxt->extElements, name, URI);
- if (ret != NULL)
- return (ret);
+ if (ret != NULL) {
+ xmlMutexUnlock(xsltExtMutex);
+ return(ret);
+ }
}
- return xsltExtModuleElementLookup(name, URI);
+
+ xmlMutexUnlock(xsltExtMutex);
+
+ ret = xsltExtModuleElementLookup(name, URI);
+
+ return (ret);
}
/**
@@ -1614,10 +1698,14 @@ xsltExtModuleElementLookup(const xmlChar * name, const xmlChar * URI)
if ((xsltElementsHash == NULL) || (name == NULL) || (URI == NULL))
return (NULL);
- ext = (xsltExtElementPtr) xmlHashLookup2(xsltElementsHash, name, URI);
+ xmlMutexLock(xsltExtMutex);
- /* if function lookup fails, attempt a dynamic load on supported platforms */
ext = (xsltExtElementPtr) xmlHashLookup2(xsltElementsHash, name, URI);
+
+ /*
+ * if function lookup fails, attempt a dynamic load on
+ * supported platforms
+ */
if (NULL == ext) {
if (!xsltExtModuleRegisterDynamic(URI)) {
ext = (xsltExtElementPtr)
@@ -1625,6 +1713,8 @@ xsltExtModuleElementLookup(const xmlChar * name, const xmlChar * URI)
}
}
+ xmlMutexUnlock(xsltExtMutex);
+
if (ext == NULL)
return (NULL);
return (ext->transform);
@@ -1648,6 +1738,8 @@ xsltExtModuleElementPreComputeLookup(const xmlChar * name,
if ((xsltElementsHash == NULL) || (name == NULL) || (URI == NULL))
return (NULL);
+ xmlMutexLock(xsltExtMutex);
+
ext = (xsltExtElementPtr) xmlHashLookup2(xsltElementsHash, name, URI);
if (ext == NULL) {
@@ -1656,6 +1748,7 @@ xsltExtModuleElementPreComputeLookup(const xmlChar * name,
xmlHashLookup2(xsltElementsHash, name, URI);
}
}
+ xmlMutexUnlock(xsltExtMutex);
if (ext == NULL)
return (NULL);
@@ -1674,11 +1767,19 @@ xsltExtModuleElementPreComputeLookup(const xmlChar * name,
int
xsltUnregisterExtModuleElement(const xmlChar * name, const xmlChar * URI)
{
+ int ret;
+
if ((xsltElementsHash == NULL) || (name == NULL) || (URI == NULL))
return (-1);
- return xmlHashRemoveEntry2(xsltElementsHash, name, URI,
- (xmlHashDeallocator) xsltFreeExtElement);
+ xmlMutexLock(xsltExtMutex);
+
+ ret = xmlHashRemoveEntry2(xsltElementsHash, name, URI,
+ (xmlHashDeallocator) xsltFreeExtElement);
+
+ xmlMutexUnlock(xsltExtMutex);
+
+ return(ret);
}
/**
@@ -1689,8 +1790,12 @@ xsltUnregisterExtModuleElement(const xmlChar * name, const xmlChar * URI)
static void
xsltUnregisterAllExtModuleElement(void)
{
+ xmlMutexLock(xsltExtMutex);
+
xmlHashFree(xsltElementsHash, (xmlHashDeallocator) xsltFreeExtElement);
xsltElementsHash = NULL;
+
+ xmlMutexUnlock(xsltExtMutex);
}
/**
@@ -1715,9 +1820,13 @@ xsltRegisterExtModuleTopLevel(const xmlChar * name, const xmlChar * URI,
if (xsltTopLevelsHash == NULL)
return (-1);
+ xmlMutexLock(xsltExtMutex);
+
xmlHashUpdateEntry2(xsltTopLevelsHash, name, URI,
XML_CAST_FPTR(function), NULL);
+ xmlMutexUnlock(xsltExtMutex);
+
return (0);
}
@@ -1738,6 +1847,8 @@ xsltExtModuleTopLevelLookup(const xmlChar * name, const xmlChar * URI)
if ((xsltTopLevelsHash == NULL) || (name == NULL) || (URI == NULL))
return (NULL);
+ xmlMutexLock(xsltExtMutex);
+
XML_CAST_FPTR(ret) = xmlHashLookup2(xsltTopLevelsHash, name, URI);
/* if lookup fails, attempt a dynamic load on supported platforms */
@@ -1747,6 +1858,8 @@ xsltExtModuleTopLevelLookup(const xmlChar * name, const xmlChar * URI)
}
}
+ xmlMutexUnlock(xsltExtMutex);
+
return (ret);
}
@@ -1762,10 +1875,18 @@ xsltExtModuleTopLevelLookup(const xmlChar * name, const xmlChar * URI)
int
xsltUnregisterExtModuleTopLevel(const xmlChar * name, const xmlChar * URI)
{
+ int ret;
+
if ((xsltTopLevelsHash == NULL) || (name == NULL) || (URI == NULL))
return (-1);
- return xmlHashRemoveEntry2(xsltTopLevelsHash, name, URI, NULL);
+ xmlMutexLock(xsltExtMutex);
+
+ ret = xmlHashRemoveEntry2(xsltTopLevelsHash, name, URI, NULL);
+
+ xmlMutexUnlock(xsltExtMutex);
+
+ return(ret);
}
/**
@@ -1776,8 +1897,12 @@ xsltUnregisterExtModuleTopLevel(const xmlChar * name, const xmlChar * URI)
static void
xsltUnregisterAllExtModuleTopLevel(void)
{
+ xmlMutexLock(xsltExtMutex);
+
xmlHashFree(xsltTopLevelsHash, NULL);
xsltTopLevelsHash = NULL;
+
+ xmlMutexUnlock(xsltExtMutex);
}
/**
@@ -2088,6 +2213,7 @@ xsltExtStyleShutdownTest(xsltStylesheetPtr style ATTRIBUTE_UNUSED,
void
xsltRegisterTestModule(void)
{
+ xsltInitGlobals();
xsltRegisterExtModuleFull((const xmlChar *) XSLT_DEFAULT_URL,
xsltExtInitTest, xsltExtShutdownTest,
xsltExtStyleInitTest,
@@ -2102,7 +2228,8 @@ xsltRegisterTestModule(void)
}
static void
-xsltHashScannerModuleFree(void *payload, void *data ATTRIBUTE_UNUSED,
+xsltHashScannerModuleFree(void *payload ATTRIBUTE_UNUSED,
+ void *data ATTRIBUTE_UNUSED,
xmlChar * name ATTRIBUTE_UNUSED)
{
#ifdef WITH_MODULES
@@ -2111,6 +2238,19 @@ xsltHashScannerModuleFree(void *payload, void *data ATTRIBUTE_UNUSED,
}
/**
+ * xsltInitGlobals:
+ *
+ * Initialize the global variables for extensions
+ */
+void
+xsltInitGlobals(void)
+{
+ if (xsltExtMutex == NULL) {
+ xsltExtMutex = xmlNewMutex();
+ }
+}
+
+/**
* xsltCleanupGlobals:
*
* Unregister all global variables set up by the XSLT library
@@ -2123,13 +2263,17 @@ xsltCleanupGlobals(void)
xsltUnregisterAllExtModuleElement();
xsltUnregisterAllExtModuleTopLevel();
+ xmlMutexLock(xsltExtMutex);
/* cleanup dynamic module hash */
if (NULL != xsltModuleHash) {
xmlHashScan(xsltModuleHash, xsltHashScannerModuleFree, 0);
xmlHashFree(xsltModuleHash, NULL);
xsltModuleHash = NULL;
}
+ xmlMutexUnlock(xsltExtMutex);
+ xmlFreeMutex(xsltExtMutex);
+ xsltExtMutex = NULL;
xsltUninit();
}
@@ -2172,25 +2316,31 @@ xsltDebugDumpExtensions(FILE * output)
fprintf(output, "No registered extension functions\n");
else {
fprintf(output, "Registered Extension Functions:\n");
+ xmlMutexLock(xsltExtMutex);
xmlHashScanFull(xsltFunctionsHash,
(xmlHashScannerFull)
xsltDebugDumpExtensionsCallback, output);
+ xmlMutexUnlock(xsltExtMutex);
}
if (!xsltElementsHash)
fprintf(output, "\nNo registered extension elements\n");
else {
fprintf(output, "\nRegistered Extension Elements:\n");
+ xmlMutexLock(xsltExtMutex);
xmlHashScanFull(xsltElementsHash,
(xmlHashScannerFull)
xsltDebugDumpExtensionsCallback, output);
+ xmlMutexUnlock(xsltExtMutex);
}
if (!xsltExtensionsHash)
fprintf(output, "\nNo registered extension modules\n");
else {
fprintf(output, "\nRegistered Extension Modules:\n");
+ xmlMutexLock(xsltExtMutex);
xmlHashScanFull(xsltExtensionsHash,
(xmlHashScannerFull)
xsltDebugDumpExtModulesCallback, output);
+ xmlMutexUnlock(xsltExtMutex);
}
}
diff --git a/libxslt/extensions.h b/libxslt/extensions.h
index c6b0cba..900779c 100644
--- a/libxslt/extensions.h
+++ b/libxslt/extensions.h
@@ -24,6 +24,16 @@ extern "C" {
*/
/**
+ * xsltInitGlobals:
+ *
+ * Initialize the global variables for extensions
+ *
+ */
+
+XSLTPUBFUN void XSLTCALL
+ xsltInitGlobals (void);
+
+/**
* xsltStyleExtInitFunction:
* @ctxt: an XSLT stylesheet
* @URI: the namespace URI for the extension
@@ -86,11 +96,11 @@ XSLTPUBFUN int XSLTCALL
XSLTPUBFUN int XSLTCALL
xsltUnregisterExtModule (const xmlChar * URI);
-XSLTPUBFUN void * XSLTCALL
+XSLTPUBFUN void * XSLTCALL
xsltGetExtData (xsltTransformContextPtr ctxt,
const xmlChar *URI);
-XSLTPUBFUN void * XSLTCALL
+XSLTPUBFUN void * XSLTCALL
xsltStyleGetExtData (xsltStylesheetPtr style,
const xmlChar *URI);
#ifdef XSLT_REFACTORED
@@ -99,29 +109,29 @@ XSLTPUBFUN void * XSLTCALL
xsltStylesheetPtr style,
const xmlChar * URI);
#endif
-XSLTPUBFUN void XSLTCALL
- xsltShutdownCtxtExts (xsltTransformContextPtr ctxt);
+XSLTPUBFUN void XSLTCALL
+ xsltShutdownCtxtExts (xsltTransformContextPtr ctxt);
-XSLTPUBFUN void XSLTCALL
- xsltShutdownExts (xsltStylesheetPtr style);
+XSLTPUBFUN void XSLTCALL
+ xsltShutdownExts (xsltStylesheetPtr style);
-XSLTPUBFUN xsltTransformContextPtr XSLTCALL
- xsltXPathGetTransformContext
+XSLTPUBFUN xsltTransformContextPtr XSLTCALL
+ xsltXPathGetTransformContext
(xmlXPathParserContextPtr ctxt);
/*
* extension functions
*/
-XSLTPUBFUN int XSLTCALL
- xsltRegisterExtModuleFunction
+XSLTPUBFUN int XSLTCALL
+ xsltRegisterExtModuleFunction
(const xmlChar *name,
const xmlChar *URI,
xmlXPathFunction function);
XSLTPUBFUN xmlXPathFunction XSLTCALL
xsltExtModuleFunctionLookup (const xmlChar *name,
const xmlChar *URI);
-XSLTPUBFUN int XSLTCALL
- xsltUnregisterExtModuleFunction
+XSLTPUBFUN int XSLTCALL
+ xsltUnregisterExtModuleFunction
(const xmlChar *name,
const xmlChar *URI);
@@ -129,7 +139,7 @@ XSLTPUBFUN int XSLTCALL
* extension elements
*/
typedef xsltElemPreCompPtr (*xsltPreComputeFunction)
- (xsltStylesheetPtr style,
+ (xsltStylesheetPtr style,
xmlNodePtr inst,
xsltTransformFunction function);
@@ -137,33 +147,33 @@ XSLTPUBFUN xsltElemPreCompPtr XSLTCALL
xsltNewElemPreComp (xsltStylesheetPtr style,
xmlNodePtr inst,
xsltTransformFunction function);
-XSLTPUBFUN void XSLTCALL
+XSLTPUBFUN void XSLTCALL
xsltInitElemPreComp (xsltElemPreCompPtr comp,
xsltStylesheetPtr style,
xmlNodePtr inst,
xsltTransformFunction function,
xsltElemPreCompDeallocator freeFunc);
-XSLTPUBFUN int XSLTCALL
- xsltRegisterExtModuleElement
+XSLTPUBFUN int XSLTCALL
+ xsltRegisterExtModuleElement
(const xmlChar *name,
const xmlChar *URI,
xsltPreComputeFunction precomp,
xsltTransformFunction transform);
-XSLTPUBFUN xsltTransformFunction XSLTCALL
+XSLTPUBFUN xsltTransformFunction XSLTCALL
xsltExtElementLookup (xsltTransformContextPtr ctxt,
const xmlChar *name,
const xmlChar *URI);
-XSLTPUBFUN xsltTransformFunction XSLTCALL
+XSLTPUBFUN xsltTransformFunction XSLTCALL
xsltExtModuleElementLookup
(const xmlChar *name,
const xmlChar *URI);
-XSLTPUBFUN xsltPreComputeFunction XSLTCALL
- xsltExtModuleElementPreComputeLookup
+XSLTPUBFUN xsltPreComputeFunction XSLTCALL
+ xsltExtModuleElementPreComputeLookup
(const xmlChar *name,
const xmlChar *URI);
-XSLTPUBFUN int XSLTCALL
- xsltUnregisterExtModuleElement
+XSLTPUBFUN int XSLTCALL
+ xsltUnregisterExtModuleElement
(const xmlChar *name,
const xmlChar *URI);
@@ -173,28 +183,28 @@ XSLTPUBFUN int XSLTCALL
typedef void (*xsltTopLevelFunction) (xsltStylesheetPtr style,
xmlNodePtr inst);
-XSLTPUBFUN int XSLTCALL
+XSLTPUBFUN int XSLTCALL
xsltRegisterExtModuleTopLevel
(const xmlChar *name,
const xmlChar *URI,
xsltTopLevelFunction function);
-XSLTPUBFUN xsltTopLevelFunction XSLTCALL
- xsltExtModuleTopLevelLookup
+XSLTPUBFUN xsltTopLevelFunction XSLTCALL
+ xsltExtModuleTopLevelLookup
(const xmlChar *name,
const xmlChar *URI);
-XSLTPUBFUN int XSLTCALL
- xsltUnregisterExtModuleTopLevel
+XSLTPUBFUN int XSLTCALL
+ xsltUnregisterExtModuleTopLevel
(const xmlChar *name,
const xmlChar *URI);
/* These 2 functions are deprecated for use within modules. */
-XSLTPUBFUN int XSLTCALL
+XSLTPUBFUN int XSLTCALL
xsltRegisterExtFunction (xsltTransformContextPtr ctxt,
const xmlChar *name,
const xmlChar *URI,
xmlXPathFunction function);
-XSLTPUBFUN int XSLTCALL
+XSLTPUBFUN int XSLTCALL
xsltRegisterExtElement (xsltTransformContextPtr ctxt,
const xmlChar *name,
const xmlChar *URI,
@@ -205,24 +215,24 @@ XSLTPUBFUN int XSLTCALL
* Those are used by the XSLT (pre)processor.
*/
-XSLTPUBFUN int XSLTCALL
+XSLTPUBFUN int XSLTCALL
xsltRegisterExtPrefix (xsltStylesheetPtr style,
const xmlChar *prefix,
const xmlChar *URI);
-XSLTPUBFUN int XSLTCALL
+XSLTPUBFUN int XSLTCALL
xsltCheckExtPrefix (xsltStylesheetPtr style,
const xmlChar *URI);
XSLTPUBFUN int XSLTCALL
xsltCheckExtURI (xsltStylesheetPtr style,
const xmlChar *URI);
-XSLTPUBFUN int XSLTCALL
+XSLTPUBFUN int XSLTCALL
xsltInitCtxtExts (xsltTransformContextPtr ctxt);
-XSLTPUBFUN void XSLTCALL
+XSLTPUBFUN void XSLTCALL
xsltFreeCtxtExts (xsltTransformContextPtr ctxt);
-XSLTPUBFUN void XSLTCALL
+XSLTPUBFUN void XSLTCALL
xsltFreeExts (xsltStylesheetPtr style);
-XSLTPUBFUN xsltElemPreCompPtr XSLTCALL
+XSLTPUBFUN xsltElemPreCompPtr XSLTCALL
xsltPreComputeExtModuleElement
(xsltStylesheetPtr style,
xmlNodePtr inst);
@@ -231,16 +241,16 @@ XSLTPUBFUN xsltElemPreCompPtr XSLTCALL
* Used by exslt initialisation
*/
-XSLTPUBFUN xmlHashTablePtr XSLTCALL
- xsltGetExtInfo (xsltStylesheetPtr style,
+XSLTPUBFUN xmlHashTablePtr XSLTCALL
+ xsltGetExtInfo (xsltStylesheetPtr style,
const xmlChar *URI);
/**
* Test module http://xmlsoft.org/XSLT/
*/
-XSLTPUBFUN void XSLTCALL
+XSLTPUBFUN void XSLTCALL
xsltRegisterTestModule (void);
-XSLTPUBFUN void XSLTCALL
+XSLTPUBFUN void XSLTCALL
xsltDebugDumpExtensions (FILE * output);
diff --git a/libxslt/security.c b/libxslt/security.c
index 4130729..b766cf7 100644
--- a/libxslt/security.c
+++ b/libxslt/security.c
@@ -58,6 +58,7 @@
#include "xslt.h"
#include "xsltInternals.h"
#include "xsltutils.h"
+#include "extensions.h"
#include "security.h"
@@ -88,6 +89,8 @@ xsltSecurityPrefsPtr
xsltNewSecurityPrefs(void) {
xsltSecurityPrefsPtr ret;
+ xsltInitGlobals();
+
ret = (xsltSecurityPrefsPtr) xmlMalloc(sizeof(xsltSecurityPrefs));
if (ret == NULL) {
xsltTransformError(NULL, NULL, NULL,
@@ -124,6 +127,7 @@ xsltFreeSecurityPrefs(xsltSecurityPrefsPtr sec) {
int
xsltSetSecurityPrefs(xsltSecurityPrefsPtr sec, xsltSecurityOption option,
xsltSecurityCheck func) {
+ xsltInitGlobals();
if (sec == NULL)
return(-1);
switch (option) {
@@ -177,6 +181,7 @@ xsltGetSecurityPrefs(xsltSecurityPrefsPtr sec, xsltSecurityOption option) {
*/
void
xsltSetDefaultSecurityPrefs(xsltSecurityPrefsPtr sec) {
+
xsltDefaultSecurityPrefs = sec;
}
diff --git a/libxslt/transform.c b/libxslt/transform.c
index da37503..861f8cf 100644
--- a/libxslt/transform.c
+++ b/libxslt/transform.c
@@ -419,6 +419,8 @@ xsltNewTransformContext(xsltStylesheetPtr style, xmlDocPtr doc) {
xsltDocumentPtr docu;
int i;
+ xsltInitGlobals();
+
cur = (xsltTransformContextPtr) xmlMalloc(sizeof(xsltTransformContext));
if (cur == NULL) {
xsltTransformError(NULL, NULL, (xmlNodePtr)doc,
@@ -5836,6 +5838,8 @@ xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
xsltStackElemPtr variables;
xsltStackElemPtr vptr;
+ xsltInitGlobals();
+
if ((style == NULL) || (doc == NULL))
return (NULL);
diff --git a/libxslt/xslt.c b/libxslt/xslt.c
index f35ad23..e88141d 100644
--- a/libxslt/xslt.c
+++ b/libxslt/xslt.c
@@ -6289,6 +6289,7 @@ xsltParseStylesheetProcess(xsltStylesheetPtr style, xmlDocPtr doc)
xmlNodePtr cur;
int oldIsSimplifiedStylesheet;
+ xsltInitGlobals();
if ((style == NULL) || (doc == NULL))
return(NULL);
@@ -6345,6 +6346,8 @@ xsltStylesheetPtr
xsltParseStylesheetProcess(xsltStylesheetPtr ret, xmlDocPtr doc) {
xmlNodePtr cur;
+ xsltInitGlobals();
+
if (doc == NULL)
return(NULL);
if (ret == NULL)
@@ -6631,6 +6634,8 @@ xsltStylesheetPtr
xsltParseStylesheetDoc(xmlDocPtr doc) {
xsltStylesheetPtr ret;
+ xsltInitGlobals();
+
ret = xsltParseStylesheetImportedDoc(doc, NULL);
if (ret == NULL)
return(NULL);
@@ -6665,6 +6670,7 @@ xsltParseStylesheetFile(const xmlChar* filename) {
xsltStylesheetPtr ret;
xmlDocPtr doc;
+ xsltInitGlobals();
if (filename == NULL)
return(NULL);
@@ -6826,6 +6832,8 @@ xsltLoadStylesheetPI(xmlDocPtr doc) {
xmlChar *href = NULL;
xmlURIPtr URI;
+ xsltInitGlobals();
+
if (doc == NULL)
return(NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]