Add important patches from upstream, including a fix for a DoS vulnerability (CVE...
authorAlexandre Rostovtsev <tetromino@gentoo.org>
Sun, 19 Apr 2015 16:09:24 +0000 (16:09 +0000)
committerAlexandre Rostovtsev <tetromino@gentoo.org>
Sun, 19 Apr 2015 16:09:24 +0000 (16:09 +0000)
Package-Manager: portage-2.2.18/cvs/Linux x86_64
Manifest-Sign-Key: 0x18E5B6F2D8D5EC8D

dev-libs/libxml2/ChangeLog
dev-libs/libxml2/Manifest
dev-libs/libxml2/files/libxml2-2.9.2-constant-memory.patch [new file with mode: 0644]
dev-libs/libxml2/files/libxml2-2.9.2-missing-entities.patch [new file with mode: 0644]
dev-libs/libxml2/files/libxml2-2.9.2-threads-declarations.patch [new file with mode: 0644]
dev-libs/libxml2/files/libxml2-2.9.2-timsort.patch [new file with mode: 0644]
dev-libs/libxml2/libxml2-2.9.2-r1.ebuild [new file with mode: 0644]

index d7f3b1e65058460e25d15461a017167500b0f80e..188d9764a4802bcdeebc7c5731f8982de9773671 100644 (file)
@@ -1,6 +1,16 @@
 # ChangeLog for dev-libs/libxml2
 # Copyright 1999-2015 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/dev-libs/libxml2/ChangeLog,v 1.443 2015/04/08 17:51:56 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/dev-libs/libxml2/ChangeLog,v 1.444 2015/04/19 16:09:17 tetromino Exp $
+
+*libxml2-2.9.2-r1 (19 Apr 2015)
+
+  19 Apr 2015; Alexandre Rostovtsev <tetromino@gentoo.org>
+  +libxml2-2.9.2-r1.ebuild, +files/libxml2-2.9.2-constant-memory.patch,
+  +files/libxml2-2.9.2-missing-entities.patch,
+  +files/libxml2-2.9.2-threads-declarations.patch,
+  +files/libxml2-2.9.2-timsort.patch:
+  Add important patches from upstream, including a fix for a DoS vulnerability
+  (CVE-2015-1819, bug #546720, thanks to Agostino Sarubbo).
 
   08 Apr 2015; Michał Górny <mgorny@gentoo.org> libxml2-2.9.2.ebuild:
   Drop old Python implementations
index 0bf976e274e05ef7ebd079f1bddfdba3fe8c8a78..b0528b2d02d4cd23793549fd911d805733ca8a3d 100644 (file)
@@ -3,31 +3,36 @@ Hash: SHA256
 
 AUX libxml2-2.7.1-catalog_path.patch 2209 SHA256 b3343f0611f9cb6e55bf62047a988653e3e9cc50f194b18adbc330b455236290 SHA512 99c1953865c560d2b7a01cf5fd61b1c5150857f3df8a9753ca583f6ff0a99e01c02d2586bb12220a615cf9c40a540dbe0d17996c0547bc0d20cbeefd6b45682d WHIRLPOOL 9b4daf434b38a0ae8103f02625ae033e7a94012a18cabc981f34b93fe8b422477905b74cfee300eb6a37e1af8bd358dd84804a5d0b6be8645ae9ee3e4c6fcd9b
 AUX libxml2-2.8.0_rc1-winnt.patch 2392 SHA256 c18b2c15550b3ff4709a85cd18d16368928319b1b7fd8875dc34acd67076b134 SHA512 e78d010c82f18386b4f0ff84497585755b43416563bccd11f8e4dbf0153ca8842934fe05dce6c2373d8360574a2165795a78ea991682aed9610000d2bfcb0164 WHIRLPOOL a87eefa17ad113ae4aed14744715b4e1781e0869a3bb789bdf4f243bdb3687d0d4b6ee2addc85bf5b2f86b9d1cc442d946f0329011f033e3a7855ae0ad79b745
+AUX libxml2-2.9.2-constant-memory.patch 6332 SHA256 0c3be9bf93626ae9c6f5517d68515acf272beda14575ecc38b282502b0c032dc SHA512 ebc428f6c1a74162b4a1d5cba09631ab9d10eb71a64d2f13248b27bf19f4f5eb14655f431b788b507b2e743ce5855b2c54deab1be257366261671442d49c6074 WHIRLPOOL d98d91783eb5d8108963f86a8dfcbc372ceacccf3ee354a0abebcace5772f601801c7131085a1b031c9cf29d8dbded8a66ed6d10f9832932e4ad9fa95e98efe6
 AUX libxml2-2.9.2-icu-pkgconfig.patch 653 SHA256 b7e0e8ce27990d1ad8ef8eb3372a6cb9f8d7de5b0674613082ec3f6cdf214af1 SHA512 516fe55dc1500146e3fb1b8cf1c567aca668f54e65d7b595694cf668278217f0c2c82a03201dcdb463f8d5adda2620b42176a799bbaf2e1521500f8ed3971601 WHIRLPOOL f49a55065ab1a7d4159aa32b3182ae79c0b1d753f4aa81ef109eb38a2baa86c53a2ac98c391eebf0d1152206ec967adc1e4b41d6bbdabe3e6de791360d5c17af
+AUX libxml2-2.9.2-missing-entities.patch 1139 SHA256 8cf04e6355d0ca8d1e96fb5e5e92819d395609f07aa5fe7e4876efc6023485d6 SHA512 4ab3ea64010f194acf5ba92268db42487234096896e0dfe00eafdaff00dcb0a3b692824e6acb4bfc072e44a41b65c7fafffad2eb3fad2e2c55874c166fc919aa WHIRLPOOL b397f2415bfed48f13d6547a42cdcd52054aaae1b168eae8bd3daf451392942347cb31d0a92b3f7cbc67cc8ad22dcf6423aba319d4eaed054d37f16d5d6bccbd
 AUX libxml2-2.9.2-revert-missing-initialization.patch 715 SHA256 160258250f519b9d71e7d4ba913df6b2ba6109e1ac533bd19a3061ffbe82cd18 SHA512 cdad2b866684cc3193a5f3254339659e28ab4af988ba257ac0c41d42bf18c82665127cc705d36313f3bd4e5d6e1bb5bab0e966e9068398c62755ba54adea6b17 WHIRLPOOL 9addff866a02bee035b7aeccd4bd50baa74b0104c166cf02927fd779c92e41b119896a7fb2dcd0e255c7614018a80585b37f954ec36ae1a5871e0f885baff187
+AUX libxml2-2.9.2-threads-declarations.patch 1505 SHA256 2b6c128ffe2008067fa92d440e4d77764cc0e98d7d654a8216dbd5ddd9c0f7fa SHA512 a8f1cc01879d3e35312ace8d47f248480c380e12220be686dc65aaa5f1b9bb13e27606c56f0c657e5a294e630d669a7884a450f6476e4c581655d393de9e7e18 WHIRLPOOL 9569285cf69c834943647911d6b0e8652601c5305fcfd056895698c4f853614f1271da16a80416c2f7e7e83fa8ae63e817f1b772bfadf61376b5840bd02a1df6
+AUX libxml2-2.9.2-timsort.patch 3801 SHA256 eff9c354f9314cf08346a42364247dea79cd0472fd892a52656ed5bdbadeffff SHA512 d9d6849867005ae2ba9358c9db2f03d9f31a74136c0dacda3b36940224ae0d95d5dbeb06be8dd3e4df363cbe76f92e854294200db17be93c80b3542bf7a8f8cb WHIRLPOOL f30524faae0469a37377fdc3b053c5fb5040e9fb627a1ba7d2e7079ab0ee5347bb2bcfdf3ff6f27dee9045250edb159fac9bf6235c66cf5bc414a99c6d93a8b0
 DIST libxml2-2.9.2.tar.gz 5444991 SHA256 5178c30b151d044aefb1b08bf54c3003a0ac55c59c866763997529d60770d5bc SHA512 a4e3b20e2efceed39c20379b32b746d4a1cf65c0cf7719d26c9bf7483c1f04a4e5a442ae2f36dc4ae8a4d011b67cfb58d9f6d0be034fa3e897a49059c9289565 WHIRLPOOL d7a77cb6ad49533cf62f6a759668e297a60dd7f70c9e13b29f682c64dfb25ae46eb9db552500130f40e3f969897bda996001d18236a4630e3713f6dd5acbe686
 DIST xmlts20080827.tar.gz 638940 SHA256 96151685cec997e1f9f3387e3626d61e6284d4d6e66e0e440c209286c03e9cc7 SHA512 7325d0977c4427fc4944b291ccf896a665f654cc24399e5565c12a849c2bc3aef4fa3ee42a09ac115abcb6570c51a8fbd052c38d64d164279ecdecad5a4e884d WHIRLPOOL 50835380c3ea208df0bf9ce032ed2df69c4c6cb5a53ffdd39a08fb4f1d166f311b2ef2fe0d9911ae1ebff92aeb42f6ea55e727dfe0b7a3b95e6c7240315b3eda
 DIST xsts-2002-01-16.tar.gz 6894439 SHA256 55e5c08db29946a91ea8e70e8f2418d3fd30d8b6777941dfba7f54726ffd9914 SHA512 43300af6d39c1e2221b0ed7318fe14c7464eeb6eb030ed1e22eb29b4ab17f014e2a4c8887c3a46ae5d243e3072da27f00f4e285498ae6f1288177d38d1108288 WHIRLPOOL 84dd51959460a4f8aa582d57ad39229c546ca7fe155012c57c368b59f5d31400d8b940a343a7320058330ca611303139cacdffed514783f96406ac5366026b11
 DIST xsts-2004-01-14.tar.gz 2761085 SHA256 09bdf9f81f381ebf9bc158a9472e498e896f7a02eb7461146e9abe1b9493ca17 SHA512 32854388d7e720ad67156baf50bf2bae7bd878ca3e35fd7e44e57cad3f434f69d56bbbedd61509f8a1faf01c9eae74a078df8fe130780b182c05c05cb1c39ebe WHIRLPOOL c46a3bf7d6dd771757f4304995cc177cf51c6cdd0e9778851fc13d3809c7b984690b4f273b3e075abe018110968eb7fc78f5b83170d3e18bacf00a4ed64b213d
+EBUILD libxml2-2.9.2-r1.ebuild 6724 SHA256 3076c18f15dcd3d22aed0fc82fe6568c183dec7f15ec7eae2a32c44adbc0fab0 SHA512 3af3501fdefb72c41dc5c4c2c750f18fac9cbc30e9c1c16a0ae3bcb728de1ddeb83130904f4e3bed037ebe2daf465c7c3181b4bf5efb66301204209b3ceb1b51 WHIRLPOOL 2d6a4e2752e74f23d1964de64097da4f3eca2e03a051ae7e3182df4928d0f9da65e23d605888d99872053b4c7058c9c465ef2e5379570f2ad15e1db77880fe4d
 EBUILD libxml2-2.9.2.ebuild 6500 SHA256 673b79f95dbe6ec1743240487585ca67ee0bb03ceb722b92e9313e8b3a3d0c25 SHA512 83da0196554d5b3af6be2d6c58ebc227f6aae8e03e7e7a0c6a1e6338dea0235c805ca07e497b58591a3f392761b743d4a88847f82fb50830c77e39dc4f756319 WHIRLPOOL 14452df05972fad2be967bec3fa2af7f5c8ee98545e51149189f86ea748d6aa7f32a4ad97435ec6fea5bdabc4b3a446d38b7f55510ff0f5c27e52fb957208d28
-MISC ChangeLog 63628 SHA256 ff8bef6b99fd2fb6e78323aeaaa8ec03941a7f6be8d291a8419984989b3e2bcf SHA512 c290b736efd0beeb6eada48bdaa2cc30bf900c87168b644595370830d6293f9ba530e0d53c28a1135984670358e53864ca9a5dce6108475e5c3bef9f911fb958 WHIRLPOOL 9c50afb564631d8580fd0987ed6356aead7b0fa1c7aa035b8a14f086923fe03e0c289510fbbd00057b4eca0305a4e5c863e8b5bbf43a70fddf13b7f765bc5c46
+MISC ChangeLog 64071 SHA256 3a3b76a85ba41c22cac23bea6961d782777a2bcfabc3ac6679a27d9c0da39e0a SHA512 62e4031c8cd4c8207f869ba832d8d43ee623d5e17d73402f770a381cf6d654f61ba6728565d7d476633927a7f48902f33ce71485e7291f54138c435765f9d1cf WHIRLPOOL 26a5bb21e4346c021c5b3c332679bdbd68a91c83ccf66144e9f07bc2571893bdfdec40028ecc83ddb12f567cd481aba4b8fce4dbac868d753d96b63f416c77eb
 MISC metadata.xml 240 SHA256 5dcdc1a8fd86d82f00a60bb322fb4f8a579d75ec7be2398164435197ab3903df SHA512 d673fbe248c2fcdf401f91f8d0e15587fd9f94c604d62f7864931f379b35a3ffc20264ae9668661a0d09693cd42db30c7f74fcb606da812312e394272acfeec8 WHIRLPOOL 4d2cc2b44bc446377dc659162e9f638650e82564a3328b0b23c1e6f197e88b9ae545d8778c69829a6f268e8b5f7d0db1b0aee1e3d8aedd909d1d756dc4aa94c3
 -----BEGIN PGP SIGNATURE-----
-Version: GnuPG v2
+Version: GnuPG v2.0
 
-iQJ8BAEBCABmBQJVJWrXXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
-ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQ2REJCMDdDQzRGMERBRDA2RUEwQUZFNDFC
-MDdBMUFFQUVGQjQ0NjRFAAoJELB6GurvtEZO21MQANyevozp+OfqxDok5eC+IkkF
-rxIRayYMGOUbL7/h1vpO60UzYEc0cjhlsJc/pEblvbUP12ucEubitUJFcUCBIEw7
-ff1Pik9FfxIWJ0jxj8a2lN/EM+yug3DXTUKOgT7ZVxMLH+B8vgEvgTy3KxSznFa+
-dnXdf5c9jDA2jlr9J00gtVBDEgOQaB5tVZMElL397s+GxbY0BZqg3Arimf7bwy4i
-MM5I0vC/zP4rul6MAJnJCOg2uAhwQzRf1518YMlh9vzL9tN85l+QFV496mBRUpao
-6E0Yd0KKEgVIbEfDJhNwJA/Q/lyEugOZOUjzzwFu/PDqjbsuwwrqWygd6w7JHkoP
-xPo5Rk1buMZ1WtUYTwbtzCy0sp1veS4Ey9KKuO1FwZgIXpvBI6SzJnmyA/5fHcaG
-32m4swGDE8wZRMRIKbdJTSQM6CGZCFEcs1r3kXnNwDl2NRGpXE2NfsBpKFqt5y+O
-Oq3iEvmIj5fYU+07YSlR/mNMVfwpj4+01iE6tvRyjrFwbYk4frgnUVTReB3pHYt6
-JUnNl9857rRUf5CwgjPjQs34PpjzjGV5WWceApXBCGjvdCmW1C6LQrZYUovKeajm
-nU6n0FVB0CuBiaM2mxT3dwrImU3uz15jKGsWR5wmSxjHiU8wgCY2zvbtyB6LjrkX
-rTIiRmEfRriWY+eSAPdX
-=rTWr
+iQJ8BAEBCABmBQJVM9MuXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
+ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQ1RTNCRkUzRDRBNkI2MEEwQkYwQzMyOEEx
+OEU1QjZGMkQ4RDVFQzhEAAoJEBjltvLY1eyNoaAP/jj1mToK5PLPmp0yzRfWhCNE
+MS0BT3PiyUT90uenEo7cRQ9B5sCMXi+/3p0ashPQ4QMlkJKeIDrHzll6OnauY97g
+jKYyxmS+V97RjPWObqJhz3T061lapicRRSEK+EzUp1bpF/jcX4YRhZea4+fFd+NA
++uvGZMlYPDg2KAi44lR7c/nhPwV6OKJ4nkTHDzxN13aW3ULa+bJf8zn/pe0hdZJm
+Xnq2e+GAtY65gpHS+FSKEv4zeNeS//hZcAO6Ynf2uRMgd2Ba3Pf4Vm2/5o6HlLQ/
+J0WzLTpXW2q9fSosBotbGK6dwzSiRRfMuhqROZ1vkQX3QDvS4BrHJYZS+mSm6XNO
+4CqS7pLaJoh3v+nuQ79gz7P9eRTwASn/wXWu4pRztMM/DCoDCklyWKssRuNbHliZ
+L3u7CSNBVQL95MoPjimyczd5kdytBeqqd7Xzb/UPZTkYsrk5ZlMgYsQhndwTDmND
+KV4o0l62WvSxuVyRUlXExsz1VMrZaOYboo7/jK4D1cesJQ4XnM8dMZolHGPfYkrD
+q3yUW9ff3l6Zn/XRdEj0Kv3RDRjfaoYTntCXk29Ov4nkbJNSjjamq0zSpoJz+98T
+pPsHwcgd57lLjoHzaMY7PETdTrHeV/z6RExahWm0LEc34JvWD1DNdnWMvetdfLot
+MqKJMefM4R39zKfM9Kok
+=havJ
 -----END PGP SIGNATURE-----
diff --git a/dev-libs/libxml2/files/libxml2-2.9.2-constant-memory.patch b/dev-libs/libxml2/files/libxml2-2.9.2-constant-memory.patch
new file mode 100644 (file)
index 0000000..dc944b6
--- /dev/null
@@ -0,0 +1,176 @@
+From 213f1fe0d76d30eaed6e5853057defc43e6df2c9 Mon Sep 17 00:00:00 2001
+From: Daniel Veillard <veillard@redhat.com>
+Date: Tue, 14 Apr 2015 17:41:48 +0800
+Subject: [PATCH] CVE-2015-1819 Enforce the reader to run in constant memory
+
+One of the operation on the reader could resolve entities
+leading to the classic expansion issue. Make sure the
+buffer used for xmlreader operation is bounded.
+Introduce a new allocation type for the buffers for this effect.
+---
+ buf.c                 | 43 ++++++++++++++++++++++++++++++++++++++++++-
+ include/libxml/tree.h |  3 ++-
+ xmlreader.c           | 20 +++++++++++++++++++-
+ 3 files changed, 63 insertions(+), 3 deletions(-)
+
+diff --git a/buf.c b/buf.c
+index 6efc7b6..07922ff 100644
+--- a/buf.c
++++ b/buf.c
+@@ -27,6 +27,7 @@
+ #include <libxml/tree.h>
+ #include <libxml/globals.h>
+ #include <libxml/tree.h>
++#include <libxml/parserInternals.h> /* for XML_MAX_TEXT_LENGTH */
+ #include "buf.h"
+ 
+ #define WITH_BUFFER_COMPAT
+@@ -299,7 +300,8 @@ xmlBufSetAllocationScheme(xmlBufPtr buf,
+     if ((scheme == XML_BUFFER_ALLOC_DOUBLEIT) ||
+         (scheme == XML_BUFFER_ALLOC_EXACT) ||
+         (scheme == XML_BUFFER_ALLOC_HYBRID) ||
+-        (scheme == XML_BUFFER_ALLOC_IMMUTABLE)) {
++        (scheme == XML_BUFFER_ALLOC_IMMUTABLE) ||
++      (scheme == XML_BUFFER_ALLOC_BOUNDED)) {
+       buf->alloc = scheme;
+         if (buf->buffer)
+             buf->buffer->alloc = scheme;
+@@ -458,6 +460,18 @@ xmlBufGrowInternal(xmlBufPtr buf, size_t len) {
+     size = buf->use + len + 100;
+ #endif
+ 
++    if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) {
++        /*
++       * Used to provide parsing limits
++       */
++        if ((buf->use + len >= XML_MAX_TEXT_LENGTH) ||
++          (buf->size >= XML_MAX_TEXT_LENGTH)) {
++          xmlBufMemoryError(buf, "buffer error: text too long\n");
++          return(0);
++      }
++      if (size >= XML_MAX_TEXT_LENGTH)
++          size = XML_MAX_TEXT_LENGTH;
++    }
+     if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) {
+         size_t start_buf = buf->content - buf->contentIO;
+ 
+@@ -739,6 +753,15 @@ xmlBufResize(xmlBufPtr buf, size_t size)
+     CHECK_COMPAT(buf)
+ 
+     if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return(0);
++    if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) {
++        /*
++       * Used to provide parsing limits
++       */
++        if (size >= XML_MAX_TEXT_LENGTH) {
++          xmlBufMemoryError(buf, "buffer error: text too long\n");
++          return(0);
++      }
++    }
+ 
+     /* Don't resize if we don't have to */
+     if (size < buf->size)
+@@ -867,6 +890,15 @@ xmlBufAdd(xmlBufPtr buf, const xmlChar *str, int len) {
+ 
+     needSize = buf->use + len + 2;
+     if (needSize > buf->size){
++      if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) {
++          /*
++           * Used to provide parsing limits
++           */
++          if (needSize >= XML_MAX_TEXT_LENGTH) {
++              xmlBufMemoryError(buf, "buffer error: text too long\n");
++              return(-1);
++          }
++      }
+         if (!xmlBufResize(buf, needSize)){
+           xmlBufMemoryError(buf, "growing buffer");
+             return XML_ERR_NO_MEMORY;
+@@ -938,6 +970,15 @@ xmlBufAddHead(xmlBufPtr buf, const xmlChar *str, int len) {
+     }
+     needSize = buf->use + len + 2;
+     if (needSize > buf->size){
++      if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) {
++          /*
++           * Used to provide parsing limits
++           */
++          if (needSize >= XML_MAX_TEXT_LENGTH) {
++              xmlBufMemoryError(buf, "buffer error: text too long\n");
++              return(-1);
++          }
++      }
+         if (!xmlBufResize(buf, needSize)){
+           xmlBufMemoryError(buf, "growing buffer");
+             return XML_ERR_NO_MEMORY;
+diff --git a/include/libxml/tree.h b/include/libxml/tree.h
+index 2f90717..4a9b3bc 100644
+--- a/include/libxml/tree.h
++++ b/include/libxml/tree.h
+@@ -76,7 +76,8 @@ typedef enum {
+     XML_BUFFER_ALLOC_EXACT,   /* grow only to the minimal size */
+     XML_BUFFER_ALLOC_IMMUTABLE, /* immutable buffer */
+     XML_BUFFER_ALLOC_IO,      /* special allocation scheme used for I/O */
+-    XML_BUFFER_ALLOC_HYBRID   /* exact up to a threshold, and doubleit thereafter */
++    XML_BUFFER_ALLOC_HYBRID,  /* exact up to a threshold, and doubleit thereafter */
++    XML_BUFFER_ALLOC_BOUNDED  /* limit the upper size of the buffer */
+ } xmlBufferAllocationScheme;
+ 
+ /**
+diff --git a/xmlreader.c b/xmlreader.c
+index f19e123..471e7e2 100644
+--- a/xmlreader.c
++++ b/xmlreader.c
+@@ -2091,6 +2091,9 @@ xmlNewTextReader(xmlParserInputBufferPtr input, const char *URI) {
+               "xmlNewTextReader : malloc failed\n");
+       return(NULL);
+     }
++    /* no operation on a reader should require a huge buffer */
++    xmlBufSetAllocationScheme(ret->buffer,
++                            XML_BUFFER_ALLOC_BOUNDED);
+     ret->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler));
+     if (ret->sax == NULL) {
+       xmlBufFree(ret->buffer);
+@@ -3616,6 +3619,7 @@ xmlTextReaderConstValue(xmlTextReaderPtr reader) {
+           return(((xmlNsPtr) node)->href);
+         case XML_ATTRIBUTE_NODE:{
+           xmlAttrPtr attr = (xmlAttrPtr) node;
++          const xmlChar *ret;
+ 
+           if ((attr->children != NULL) &&
+               (attr->children->type == XML_TEXT_NODE) &&
+@@ -3629,10 +3633,21 @@ xmlTextReaderConstValue(xmlTextReaderPtr reader) {
+                                         "xmlTextReaderSetup : malloc failed\n");
+                         return (NULL);
+                     }
++                  xmlBufSetAllocationScheme(reader->buffer,
++                                            XML_BUFFER_ALLOC_BOUNDED);
+                 } else
+                     xmlBufEmpty(reader->buffer);
+               xmlBufGetNodeContent(reader->buffer, node);
+-              return(xmlBufContent(reader->buffer));
++              ret = xmlBufContent(reader->buffer);
++              if (ret == NULL) {
++                  /* error on the buffer best to reallocate */
++                  xmlBufFree(reader->buffer);
++                  reader->buffer = xmlBufCreateSize(100);
++                  xmlBufSetAllocationScheme(reader->buffer,
++                                            XML_BUFFER_ALLOC_BOUNDED);
++                  ret = BAD_CAST "";
++              }
++              return(ret);
+           }
+           break;
+       }
+@@ -5131,6 +5146,9 @@ xmlTextReaderSetup(xmlTextReaderPtr reader,
+                         "xmlTextReaderSetup : malloc failed\n");
+         return (-1);
+     }
++    /* no operation on a reader should require a huge buffer */
++    xmlBufSetAllocationScheme(reader->buffer,
++                            XML_BUFFER_ALLOC_BOUNDED);
+     if (reader->sax == NULL)
+       reader->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler));
+     if (reader->sax == NULL) {
+-- 
+2.3.5
+
diff --git a/dev-libs/libxml2/files/libxml2-2.9.2-missing-entities.patch b/dev-libs/libxml2/files/libxml2-2.9.2-missing-entities.patch
new file mode 100644 (file)
index 0000000..7a10e20
--- /dev/null
@@ -0,0 +1,31 @@
+From 72a46a519ce7326d9a00f0b6a7f2a8e958cd1675 Mon Sep 17 00:00:00 2001
+From: Daniel Veillard <veillard@redhat.com>
+Date: Thu, 23 Oct 2014 11:35:36 +0800
+Subject: [PATCH] Fix missing entities after CVE-2014-3660 fix
+
+For https://bugzilla.gnome.org/show_bug.cgi?id=738805
+
+The fix for CVE-2014-3660 introduced a regression in some case
+where entity substitution is required and the entity is used
+first in anotther entity referenced from an attribute value
+---
+ parser.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/parser.c b/parser.c
+index 67c9dfd..a8d1b67 100644
+--- a/parser.c
++++ b/parser.c
+@@ -7235,7 +7235,8 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
+      * far more secure as the parser will only process data coming from
+      * the document entity by default.
+      */
+-    if ((ent->checked == 0) &&
++    if (((ent->checked == 0) ||
++         ((ent->children == NULL) && (ctxt->options & XML_PARSE_NOENT))) &&
+         ((ent->etype != XML_EXTERNAL_GENERAL_PARSED_ENTITY) ||
+          (ctxt->options & (XML_PARSE_NOENT | XML_PARSE_DTDVALID)))) {
+       unsigned long oldnbent = ctxt->nbentities;
+-- 
+2.3.5
+
diff --git a/dev-libs/libxml2/files/libxml2-2.9.2-threads-declarations.patch b/dev-libs/libxml2/files/libxml2-2.9.2-threads-declarations.patch
new file mode 100644 (file)
index 0000000..1236f62
--- /dev/null
@@ -0,0 +1,48 @@
+From fff8a6b87e05200a0ad0af6f86c2e859c7de9172 Mon Sep 17 00:00:00 2001
+From: Michael Heimpold <mhei@heimpold.de>
+Date: Mon, 22 Dec 2014 11:12:12 +0800
+Subject: [PATCH] threads: use forward declarations only for glibc
+
+Fixes bug #704908
+
+The declarations of pthread functions, used to generate weak references
+to them, fail to suppress macros. Thus, if any pthread function has
+been provided as a macro, compiling threads.c will fail.
+This breaks on musl libc, which defines pthread_equal as a macro (in
+addition to providing the function, as required).
+
+Prevent the declarations for e.g. musl libc by refining the condition.
+
+The idea for this solution was borrowed from the alpine linux guys, see
+http://git.alpinelinux.org/cgit/aports/tree/main/libxml2/libxml2-pthread.patch
+
+Signed-off-by: Michael Heimpold <mhei@heimpold.de>
+---
+ threads.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/threads.c b/threads.c
+index 8921204..78006a2 100644
+--- a/threads.c
++++ b/threads.c
+@@ -47,7 +47,7 @@
+ #ifdef HAVE_PTHREAD_H
+ 
+ static int libxml_is_threaded = -1;
+-#ifdef __GNUC__
++#if defined(__GNUC__) && defined(__GLIBC__)
+ #ifdef linux
+ #if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (__GNUC__ > 3)
+ extern int pthread_once (pthread_once_t *__once_control,
+@@ -89,7 +89,7 @@ extern int pthread_cond_signal ()
+          __attribute((weak));
+ #endif
+ #endif /* linux */
+-#endif /* __GNUC__ */
++#endif /* defined(__GNUC__) && defined(__GLIBC__) */
+ #endif /* HAVE_PTHREAD_H */
+ 
+ /*
+-- 
+2.3.5
+
diff --git a/dev-libs/libxml2/files/libxml2-2.9.2-timsort.patch b/dev-libs/libxml2/files/libxml2-2.9.2-timsort.patch
new file mode 100644 (file)
index 0000000..c179d47
--- /dev/null
@@ -0,0 +1,128 @@
+From 9b987f8c98763ee569bde90b5268b43474ca106c Mon Sep 17 00:00:00 2001
+From: Christopher Swenson <chris@caswenson.com>
+Date: Fri, 27 Feb 2015 14:55:49 +0800
+Subject: [PATCH] Fix timsort invariant loop re: Envisage article
+
+See http://envisage-project.eu/proving-android-java-and-python-sorting-algorithm-is-broken-and-how-to-fix-it/
+
+We use a "runLen" array of size 128, so it should be nearly impossible
+to have our implementation overflow.
+
+But in any case, the fix is relatively simple -- checking two extra
+conditions in the invariant calculation.
+
+I also took this opportunity to remove some redundancy in the
+left/right merge logic in the invariant loop.
+---
+ timsort.h | 74 +++++++++++++++++++++++++++++++++------------------------------
+ 1 file changed, 39 insertions(+), 35 deletions(-)
+
+diff --git a/timsort.h b/timsort.h
+index efa3aab..795f272 100644
+--- a/timsort.h
++++ b/timsort.h
+@@ -392,62 +392,66 @@ static void TIM_SORT_MERGE(SORT_TYPE *dst, const TIM_SORT_RUN_T *stack, const in
+ 
+ static int TIM_SORT_COLLAPSE(SORT_TYPE *dst, TIM_SORT_RUN_T *stack, int stack_curr, TEMP_STORAGE_T *store, const size_t size)
+ {
+-  while (1)
+-  {
+-    int64_t A, B, C;
++  while (1) {
++    int64_t A, B, C, D;
++    int ABC, BCD, BD, CD;
++
+     /* if the stack only has one thing on it, we are done with the collapse */
+-    if (stack_curr <= 1) break;
++    if (stack_curr <= 1) {
++      break;
++    }
++
+     /* if this is the last merge, just do it */
+-    if ((stack_curr == 2) &&
+-        (stack[0].length + stack[1].length == (int64_t) size))
+-    {
++    if ((stack_curr == 2) && (stack[0].length + stack[1].length == size)) {
+       TIM_SORT_MERGE(dst, stack, stack_curr, store);
+       stack[0].length += stack[1].length;
+       stack_curr--;
+       break;
+     }
+     /* check if the invariant is off for a stack of 2 elements */
+-    else if ((stack_curr == 2) && (stack[0].length <= stack[1].length))
+-    {
++    else if ((stack_curr == 2) && (stack[0].length <= stack[1].length)) {
+       TIM_SORT_MERGE(dst, stack, stack_curr, store);
+       stack[0].length += stack[1].length;
+       stack_curr--;
+       break;
+-    }
+-    else if (stack_curr == 2)
++    } else if (stack_curr == 2) {
+       break;
++    }
+ 
+-    A = stack[stack_curr - 3].length;
+-    B = stack[stack_curr - 2].length;
+-    C = stack[stack_curr - 1].length;
++    B = stack[stack_curr - 3].length;
++    C = stack[stack_curr - 2].length;
++    D = stack[stack_curr - 1].length;
+ 
+-    /* check first invariant */
+-    if (A <= B + C)
+-    {
+-      if (A < C)
+-      {
+-        TIM_SORT_MERGE(dst, stack, stack_curr - 1, store);
+-        stack[stack_curr - 3].length += stack[stack_curr - 2].length;
+-        stack[stack_curr - 2] = stack[stack_curr - 1];
+-        stack_curr--;
+-      }
+-      else
+-      {
+-        TIM_SORT_MERGE(dst, stack, stack_curr, store);
+-        stack[stack_curr - 2].length += stack[stack_curr - 1].length;
+-        stack_curr--;
+-      }
++    if (stack_curr >= 4) {
++      A = stack[stack_curr - 4].length;
++      ABC = (A <= B + C);
++    } else {
++      ABC = 0;
+     }
+-    /* check second invariant */
+-    else if (B <= C)
+-    {
++
++    BCD = (B <= C + D) || ABC;
++    CD = (C <= D);
++    BD = (B < D);
++
++    /* Both invariants are good */
++    if (!BCD && !CD) {
++      break;
++    }
++
++    /* left merge */
++    if (BCD && !CD) {
++      TIM_SORT_MERGE(dst, stack, stack_curr - 1, store);
++      stack[stack_curr - 3].length += stack[stack_curr - 2].length;
++      stack[stack_curr - 2] = stack[stack_curr - 1];
++      stack_curr--;
++    } else {
++      /* right merge */
+       TIM_SORT_MERGE(dst, stack, stack_curr, store);
+       stack[stack_curr - 2].length += stack[stack_curr - 1].length;
+       stack_curr--;
+     }
+-    else
+-      break;
+   }
++
+   return stack_curr;
+ }
+ 
+-- 
+2.3.5
+
diff --git a/dev-libs/libxml2/libxml2-2.9.2-r1.ebuild b/dev-libs/libxml2/libxml2-2.9.2-r1.ebuild
new file mode 100644 (file)
index 0000000..9c6add2
--- /dev/null
@@ -0,0 +1,212 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/dev-libs/libxml2/libxml2-2.9.2-r1.ebuild,v 1.1 2015/04/19 16:09:17 tetromino Exp $
+
+EAPI="5"
+PYTHON_COMPAT=( python{2_7,3_3,3_4} )
+PYTHON_REQ_USE="xml"
+
+inherit libtool flag-o-matic eutils python-r1 autotools prefix multilib-minimal
+
+DESCRIPTION="Version 2 of the library to manipulate XML files"
+HOMEPAGE="http://www.xmlsoft.org/"
+
+LICENSE="MIT"
+SLOT="2"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~ppc-aix ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~x64-freebsd ~x86-freebsd ~hppa-hpux ~ia64-hpux ~x86-interix ~amd64-linux ~arm-linux ~ia64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris ~x86-winnt"
+IUSE="debug examples icu ipv6 lzma python readline static-libs test"
+
+XSTS_HOME="http://www.w3.org/XML/2004/xml-schema-test-suite"
+XSTS_NAME_1="xmlschema2002-01-16"
+XSTS_NAME_2="xmlschema2004-01-14"
+XSTS_TARBALL_1="xsts-2002-01-16.tar.gz"
+XSTS_TARBALL_2="xsts-2004-01-14.tar.gz"
+XMLCONF_TARBALL="xmlts20080827.tar.gz"
+
+SRC_URI="ftp://xmlsoft.org/${PN}/${PN}-${PV/_rc/-rc}.tar.gz
+       test? (
+               ${XSTS_HOME}/${XSTS_NAME_1}/${XSTS_TARBALL_1}
+               ${XSTS_HOME}/${XSTS_NAME_2}/${XSTS_TARBALL_2}
+               http://www.w3.org/XML/Test/${XMLCONF_TARBALL} )"
+
+COMMON_DEPEND="
+       >=sys-libs/zlib-1.2.8-r1:=[${MULTILIB_USEDEP}]
+       icu? ( >=dev-libs/icu-51.2-r1:=[${MULTILIB_USEDEP}] )
+       lzma? ( >=app-arch/xz-utils-5.0.5-r1:=[${MULTILIB_USEDEP}] )
+       python? ( ${PYTHON_DEPS} )
+       readline? ( sys-libs/readline:= )
+"
+RDEPEND="${COMMON_DEPEND}
+       abi_x86_32? ( !<=app-emulation/emul-linux-x86-baselibs-20131008-r6
+               !app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)] )
+"
+DEPEND="${COMMON_DEPEND}
+       dev-util/gtk-doc-am
+       virtual/pkgconfig
+       hppa? ( >=sys-devel/binutils-2.15.92.0.2 )
+"
+
+S="${WORKDIR}/${PN}-${PV%_rc*}"
+
+MULTILIB_CHOST_TOOLS=(
+       /usr/bin/xml2-config
+)
+
+src_unpack() {
+       # ${A} isn't used to avoid unpacking of test tarballs into $WORKDIR,
+       # as they are needed as tarballs in ${S}/xstc instead and not unpacked
+       unpack ${P/_rc/-rc}.tar.gz
+       cd "${S}"
+
+       if use test; then
+               cp "${DISTDIR}/${XSTS_TARBALL_1}" \
+                       "${DISTDIR}/${XSTS_TARBALL_2}" \
+                       "${S}"/xstc/ \
+                       || die "Failed to install test tarballs"
+               unpack ${XMLCONF_TARBALL}
+       fi
+}
+
+src_prepare() {
+       DOCS=( AUTHORS ChangeLog NEWS README* TODO* )
+
+       # Patches needed for prefix support
+       epatch "${FILESDIR}"/${PN}-2.7.1-catalog_path.patch
+       epatch "${FILESDIR}"/${PN}-2.8.0_rc1-winnt.patch
+
+       eprefixify catalog.c xmlcatalog.c runtest.c xmllint.c
+
+#      epunt_cxx # if we don't eautoreconf
+
+       # Important patches from master
+       epatch \
+               "${FILESDIR}/${PN}-2.9.2-revert-missing-initialization.patch" \
+               "${FILESDIR}/${PN}-2.9.2-missing-entities.patch" \
+               "${FILESDIR}/${PN}-2.9.2-threads-declarations.patch" \
+               "${FILESDIR}/${PN}-2.9.2-timsort.patch" \
+               "${FILESDIR}/${PN}-2.9.2-constant-memory.patch"
+
+       # Please do not remove, as else we get references to PORTAGE_TMPDIR
+       # in /usr/lib/python?.?/site-packages/libxml2mod.la among things.
+       # We now need to run eautoreconf at the end to prevent maintainer mode.
+#      elibtoolize
+
+       # Use pkgconfig to find icu to properly support multilib, upstream bug #738751
+       epatch "${FILESDIR}/${PN}-2.9.2-icu-pkgconfig.patch"
+
+       eautoreconf
+}
+
+multilib_src_configure() {
+       # filter seemingly problematic CFLAGS (#26320)
+       filter-flags -fprefetch-loop-arrays -funroll-loops
+
+       # USE zlib support breaks gnome2
+       # (libgnomeprint for instance fails to compile with
+       # fresh install, and existing) - <azarah@gentoo.org> (22 Dec 2002).
+
+       # The meaning of the 'debug' USE flag does not apply to the --with-debug
+       # switch (enabling the libxml2 debug module). See bug #100898.
+
+       # --with-mem-debug causes unusual segmentation faults (bug #105120).
+
+       libxml2_configure() {
+               ECONF_SOURCE="${S}" econf \
+                       --with-html-subdir=${PF}/html \
+                       --docdir="${EPREFIX}/usr/share/doc/${PF}" \
+                       $(use_with debug run-debug) \
+                       $(use_with icu) \
+                       $(use_with lzma) \
+                       $(use_enable ipv6) \
+                       $(use_enable static-libs static) \
+                       $(multilib_native_use_with readline) \
+                       $(multilib_native_use_with readline history) \
+                       "$@"
+       }
+
+       libxml2_py_configure() {
+               mkdir -p "${BUILD_DIR}" || die # ensure python build dirs exist
+               run_in_build_dir libxml2_configure "--with-python=${PYTHON}" # odd build system
+       }
+
+       libxml2_configure --without-python # build python bindings separately
+
+       if multilib_is_native_abi && use python; then
+               python_foreach_impl libxml2_py_configure
+       fi
+}
+
+multilib_src_compile() {
+       default
+       if multilib_is_native_abi && use python; then
+               local native_builddir=${BUILD_DIR}
+               python_foreach_impl libxml2_py_emake top_builddir="${native_builddir}" all
+       fi
+}
+
+multilib_src_test() {
+       default
+       multilib_is_native_abi && use python && python_foreach_impl libxml2_py_emake test
+}
+
+multilib_src_install() {
+       emake DESTDIR="${D}" \
+               EXAMPLES_DIR="${EPREFIX}"/usr/share/doc/${PF}/examples install
+
+       if multilib_is_native_abi && use python; then
+               python_foreach_impl libxml2_py_emake DESTDIR="${D}" install
+               python_foreach_impl python_optimize
+       fi
+}
+
+multilib_src_install_all() {
+       # on windows, xmllint is installed by interix libxml2 in parent prefix.
+       # this is the version to use. the native winnt version does not support
+       # symlinks, which makes repoman fail if the portage tree is linked in
+       # from another location (which is my default). -- mduft
+       if [[ ${CHOST} == *-winnt* ]]; then
+               rm -rf "${ED}"/usr/bin/xmllint
+               rm -rf "${ED}"/usr/bin/xmlcatalog
+       fi
+
+       rm -rf "${ED}"/usr/share/doc/${P}
+       einstalldocs
+
+       if ! use python; then
+               rm -rf "${ED}"/usr/share/doc/${PF}/python
+               rm -rf "${ED}"/usr/share/doc/${PN}-python-${PV}
+       fi
+
+       if ! use examples; then
+               rm -rf "${ED}/usr/share/doc/${PF}/examples"
+               rm -rf "${ED}/usr/share/doc/${PF}/python/examples"
+       fi
+
+       prune_libtool_files --modules
+}
+
+pkg_postinst() {
+       # We don't want to do the xmlcatalog during stage1, as xmlcatalog will not
+       # be in / and stage1 builds to ROOT=/tmp/stage1root. This fixes bug #208887.
+       if [[ "${ROOT}" != "/" ]]; then
+               elog "Skipping XML catalog creation for stage building (bug #208887)."
+       else
+               # need an XML catalog, so no-one writes to a non-existent one
+               CATALOG="${EROOT}etc/xml/catalog"
+
+               # we dont want to clobber an existing catalog though,
+               # only ensure that one is there
+               # <obz@gentoo.org>
+               if [[ ! -e ${CATALOG} ]]; then
+                       [[ -d "${EROOT}etc/xml" ]] || mkdir -p "${EROOT}etc/xml"
+                       "${EPREFIX}"/usr/bin/xmlcatalog --create > "${CATALOG}"
+                       einfo "Created XML catalog in ${CATALOG}"
+               fi
+       fi
+}
+
+libxml2_py_emake() {
+       pushd "${BUILD_DIR}/python" > /dev/null || die
+       emake "$@"
+       popd > /dev/null
+}