diff options
author | Alexandre Rostovtsev <tetromino@gentoo.org> | 2012-05-21 02:24:56 +0000 |
---|---|---|
committer | Alexandre Rostovtsev <tetromino@gentoo.org> | 2012-05-21 02:24:56 +0000 |
commit | 38f361c1551c729856aae3586c6867ca60e52672 (patch) | |
tree | 8ced276bfc15aa51663d87a8f1526b0220ffc77e /dev-libs/libxml2/files | |
parent | Tweak the last commit; drop NEWS from the patch since it won't apply cleanly. (diff) | |
download | gentoo-2-38f361c1551c729856aae3586c6867ca60e52672.tar.gz gentoo-2-38f361c1551c729856aae3586c6867ca60e52672.tar.bz2 gentoo-2-38f361c1551c729856aae3586c6867ca60e52672.zip |
Version bump with numerous bugfixes, including for bug #416209 (out-of-bounds write, CVE-2011-3102, thanks to Paweł Hajdan, Jr.). Drop old.
(Portage version: 2.2.0_alpha107/cvs/Linux x86_64)
Diffstat (limited to 'dev-libs/libxml2/files')
-rw-r--r-- | dev-libs/libxml2/files/libxml2-2.8.0_rc1-randomization-threads.patch | 210 | ||||
-rw-r--r-- | dev-libs/libxml2/files/libxml2-2.8.0_rc1-winnt.patch | 91 |
2 files changed, 301 insertions, 0 deletions
diff --git a/dev-libs/libxml2/files/libxml2-2.8.0_rc1-randomization-threads.patch b/dev-libs/libxml2/files/libxml2-2.8.0_rc1-randomization-threads.patch new file mode 100644 index 000000000000..d51801d42953 --- /dev/null +++ b/dev-libs/libxml2/files/libxml2-2.8.0_rc1-randomization-threads.patch @@ -0,0 +1,210 @@ +From 379ebc1d774865fa92f2a8d80cc4da65cbe19998 Mon Sep 17 00:00:00 2001 +From: Daniel Veillard <veillard@redhat.com> +Date: Fri, 18 May 2012 15:41:31 +0800 +Subject: [PATCH] Cleanup on randomization + +tsan reported that rand() is not thread safe, so create +a thread safe wrapper, use rand_r() if available. +Consolidate the function, initialization and cleanup in +dict.c and make sure it is initialized in xmlInitParser() +--- + dict.c | 41 ++++++++++++++++++++++++++++++++++++++--- + hash.c | 10 +--------- + include/libxml/dict.h | 15 ++++++++++----- + libxml.h | 7 +++++++ + parser.c | 1 + + 5 files changed, 57 insertions(+), 17 deletions(-) + +diff --git a/dict.c b/dict.c +index ae4966b..3579f64 100644 +--- a/dict.c ++++ b/dict.c +@@ -135,6 +135,15 @@ static xmlRMutexPtr xmlDictMutex = NULL; + */ + static int xmlDictInitialized = 0; + ++#ifdef DICT_RANDOMIZATION ++#ifdef HAVE_RAND_R ++/* ++ * Internal data for random function, protected by xmlDictMutex ++ */ ++unsigned int rand_seed = 0; ++#endif ++#endif ++ + /** + * xmlInitializeDict: + * +@@ -142,24 +151,50 @@ static int xmlDictInitialized = 0; + * this function is not thread safe, initialization should + * preferably be done once at startup + */ +-static int xmlInitializeDict(void) { ++int xmlInitializeDict(void) { + if (xmlDictInitialized) + return(1); + + if ((xmlDictMutex = xmlNewRMutex()) == NULL) + return(0); ++ xmlRMutexLock(xmlDictMutex); + + #ifdef DICT_RANDOMIZATION ++#ifdef HAVE_RAND_R ++ rand_seed = time(NULL); ++ rand_r(& rand_seed); ++#else + srand(time(NULL)); + #endif ++#endif + xmlDictInitialized = 1; ++ xmlRMutexUnlock(xmlDictMutex); + return(1); + } + ++#ifdef DICT_RANDOMIZATION ++int __xmlRandom(void) { ++ int ret; ++ ++ if (xmlDictInitialized == 0) ++ xmlInitializeDict(); ++ ++ xmlRMutexLock(xmlDictMutex); ++#ifdef HAVE_RAND_R ++ ret = rand_r(& rand_seed); ++#else ++ ret = rand(); ++#endif ++ xmlRMutexUnlock(xmlDictMutex); ++ return(ret); ++} ++#endif ++ + /** + * xmlDictCleanup: + * +- * Free the dictionary mutex. ++ * Free the dictionary mutex. Do not call unless sure the library ++ * is not in use anymore ! + */ + void + xmlDictCleanup(void) { +@@ -488,7 +523,7 @@ xmlDictCreate(void) { + if (dict->dict) { + memset(dict->dict, 0, MIN_DICT_SIZE * sizeof(xmlDictEntry)); + #ifdef DICT_RANDOMIZATION +- dict->seed = rand(); ++ dict->seed = __xmlRandom(); + #else + dict->seed = 0; + #endif +diff --git a/hash.c b/hash.c +index fe1424f..15e1efe 100644 +--- a/hash.c ++++ b/hash.c +@@ -47,10 +47,6 @@ + + /* #define DEBUG_GROW */ + +-#ifdef HASH_RANDOMIZATION +-static int hash_initialized = 0; +-#endif +- + /* + * A single entry in the hash table + */ +@@ -186,11 +182,7 @@ xmlHashCreate(int size) { + if (table->table) { + memset(table->table, 0, size * sizeof(xmlHashEntry)); + #ifdef HASH_RANDOMIZATION +- if (!hash_initialized) { +- srand(time(NULL)); +- hash_initialized = 1; +- } +- table->random_seed = rand(); ++ table->random_seed = __xmlRandom(); + #endif + return(table); + } +diff --git a/include/libxml/dict.h b/include/libxml/dict.h +index abb8339..5994868 100644 +--- a/include/libxml/dict.h ++++ b/include/libxml/dict.h +@@ -25,6 +25,11 @@ typedef struct _xmlDict xmlDict; + typedef xmlDict *xmlDictPtr; + + /* ++ * Initializer ++ */ ++XMLPUBFUN int XMLCALL xmlInitializeDict(void); ++ ++/* + * Constructor and destructor. + */ + XMLPUBFUN xmlDictPtr XMLCALL +@@ -33,28 +38,28 @@ XMLPUBFUN xmlDictPtr XMLCALL + xmlDictCreateSub(xmlDictPtr sub); + XMLPUBFUN int XMLCALL + xmlDictReference(xmlDictPtr dict); +-XMLPUBFUN void XMLCALL ++XMLPUBFUN void XMLCALL + xmlDictFree (xmlDictPtr dict); + + /* + * Lookup of entry in the dictionnary. + */ +-XMLPUBFUN const xmlChar * XMLCALL ++XMLPUBFUN const xmlChar * XMLCALL + xmlDictLookup (xmlDictPtr dict, + const xmlChar *name, + int len); +-XMLPUBFUN const xmlChar * XMLCALL ++XMLPUBFUN const xmlChar * XMLCALL + xmlDictExists (xmlDictPtr dict, + const xmlChar *name, + int len); +-XMLPUBFUN const xmlChar * XMLCALL ++XMLPUBFUN const xmlChar * XMLCALL + xmlDictQLookup (xmlDictPtr dict, + const xmlChar *prefix, + const xmlChar *name); + XMLPUBFUN int XMLCALL + xmlDictOwns (xmlDictPtr dict, + const xmlChar *str); +-XMLPUBFUN int XMLCALL ++XMLPUBFUN int XMLCALL + xmlDictSize (xmlDictPtr dict); + + /* +diff --git a/libxml.h b/libxml.h +index dfc6c64..fa3aea4 100644 +--- a/libxml.h ++++ b/libxml.h +@@ -79,6 +79,13 @@ void __xmlGlobalInitMutexLock(void); + void __xmlGlobalInitMutexUnlock(void); + void __xmlGlobalInitMutexDestroy(void); + ++#if defined(HAVE_RAND) && defined(HAVE_SRAND) && defined(HAVE_TIME) ++/* ++ * internal thread safe random function ++ */ ++int __xmlRandom(void); ++#endif ++ + #ifdef IN_LIBXML + #ifdef __GNUC__ + #ifdef PIC +diff --git a/parser.c b/parser.c +index 1b80a8c..2c38fae 100644 +--- a/parser.c ++++ b/parser.c +@@ -14178,6 +14178,7 @@ xmlInitParser(void) { + (xmlGenericError == NULL)) + initGenericErrorDefaultFunc(NULL); + xmlInitMemory(); ++ xmlInitializeDict(); + xmlInitCharEncodingHandlers(); + xmlDefaultSAXHandlerInit(); + xmlRegisterDefaultInputCallbacks(); +-- +1.7.8.6 + diff --git a/dev-libs/libxml2/files/libxml2-2.8.0_rc1-winnt.patch b/dev-libs/libxml2/files/libxml2-2.8.0_rc1-winnt.patch new file mode 100644 index 000000000000..cce3ecb058ae --- /dev/null +++ b/dev-libs/libxml2/files/libxml2-2.8.0_rc1-winnt.patch @@ -0,0 +1,91 @@ +From 168e20836fe9614dd2dd4b42006c17a783f11c48 Mon Sep 17 00:00:00 2001 +From: Markus Duft <mduft@gentoo.org> +Date: Thu, 20 Nov 2008 11:04:33 -0500 +Subject: [PATCH] Fix for ~x86-winnt + +[Alexandre Rostovtsev <tetromino@gentoo.org>: port to 2.8.0-rc1] +--- + dict.c | 2 +- + include/wsockcompat.h | 2 +- + nanohttp.c | 2 +- + xmlIO.c | 4 ++++ + 4 files changed, 7 insertions(+), 3 deletions(-) + +diff --git a/dict.c b/dict.c +index 3579f64..71e7bc6 100644 +--- a/dict.c ++++ b/dict.c +@@ -47,7 +47,7 @@ + #else + #ifdef HAVE_INTTYPES_H + #include <inttypes.h> +-#elif defined(WIN32) ++#elif defined(WIN32) || defined (__PARITY__) + typedef unsigned __int32 uint32_t; + #endif + #endif +diff --git a/include/wsockcompat.h b/include/wsockcompat.h +index c762a64..1ed822b 100644 +--- a/include/wsockcompat.h ++++ b/include/wsockcompat.h +@@ -27,7 +27,7 @@ + #endif + #endif + +-#if defined( __MINGW32__ ) || defined( _MSC_VER ) ++#if defined( __MINGW32__ ) || defined( _MSC_VER ) || defined(__PARITY__) + /* Include <errno.h> here to ensure that it doesn't get included later + * (e.g. by iconv.h) and overwrites the definition of EWOULDBLOCK. */ + #include <errno.h> +diff --git a/nanohttp.c b/nanohttp.c +index 2437fed..dbe97a7 100644 +--- a/nanohttp.c ++++ b/nanohttp.c +@@ -74,7 +74,7 @@ + #define XML_SOCKLEN_T unsigned int + #endif + +-#if defined(__MINGW32__) || defined(_WIN32_WCE) ++#if defined(__MINGW32__) || defined(_WIN32_WCE) || defined(__PARITY__) + #ifndef _WINSOCKAPI_ + #define _WINSOCKAPI_ + #endif +diff --git a/xmlIO.c b/xmlIO.c +index 73a995d..99562f6 100644 +--- a/xmlIO.c ++++ b/xmlIO.c +@@ -47,6 +47,7 @@ + #include <winnls.h> /* for CP_UTF8 */ + #endif + ++#ifndef __PARITY__ + /* Figure a portable way to know if a file is a directory. */ + #ifndef HAVE_STAT + # ifdef HAVE__STAT +@@ -82,6 +83,7 @@ + # endif + # endif + #endif ++#endif /* __PARITY__ */ + + #include <libxml/xmlmemory.h> + #include <libxml/parser.h> +@@ -657,6 +659,7 @@ xmlWrapStatUtf8(const char *path,struct stat *info) + { + #ifdef HAVE_STAT + int retval = -1; ++#ifndef __PARITY__ + wchar_t *wPath; + + wPath = __xmlIOWin32UTF8ToWChar(path); +@@ -665,6 +668,7 @@ xmlWrapStatUtf8(const char *path,struct stat *info) + retval = _wstat(wPath,info); + xmlFree(wPath); + } ++#endif + /* maybe path in native encoding */ + if(retval < 0) + retval = stat(path,info); +-- +1.7.8.6 + |