commit:     770ffdf908c3120a6c786f255f706f62c44b2b1f
Author:     Hans de Graaff <graaff <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 11 07:16:37 2016 +0000
Commit:     Hans de Graaff <graaff <AT> gentoo <DOT> org>
CommitDate: Sat Jun 11 07:17:10 2016 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=770ffdf9

dev-ruby/tidy-ext: fix security bug 561452

Package-Manager: portage-2.2.28

 dev-ruby/tidy-ext/files/11CVE-2015-5522.patch | 34 ++++++++++++++++++++++
 dev-ruby/tidy-ext/tidy-ext-0.1.14-r3.ebuild   | 41 +++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)

diff --git a/dev-ruby/tidy-ext/files/11CVE-2015-5522.patch 
b/dev-ruby/tidy-ext/files/11CVE-2015-5522.patch
new file mode 100644
index 0000000..9422098
--- /dev/null
+++ b/dev-ruby/tidy-ext/files/11CVE-2015-5522.patch
@@ -0,0 +1,34 @@
+From c18f27a58792f7fbd0b30a0ff50d6b40a82f940d Mon Sep 17 00:00:00 2001
+From: Geoff McLane <ubu...@geoffair.info>
+Date: Wed, 3 Jun 2015 20:26:03 +0200
+Subject: [PATCH] Issue #217 - avoid len going negative, ever...
+
+---
+ src/lexer.c | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/src/lexer.c b/src/lexer.c
+index 376a3d8..664f806 100644
+--- a/ext/tidy/lexer.c
++++ b/ext/tidy/lexer.c
+@@ -3739,16 +3740,17 @@ static tmbstr ParseValue( TidyDocImpl* doc, ctmbstr 
name,
+         /* and prompts attributes unless --literal-attributes is set to yes   
   */
+         /* #994841 - Whitespace is removed from value attributes              
   */
+ 
+-        if (munge &&
++        /* Issue #217 - Also only if/while (len > 0) - MUST NEVER GO 
NEGATIVE! */
++        if ((len > 0) && munge &&
+             TY_(tmbstrcasecmp)(name, "alt") &&
+             TY_(tmbstrcasecmp)(name, "title") &&
+             TY_(tmbstrcasecmp)(name, "value") &&
+             TY_(tmbstrcasecmp)(name, "prompt"))
+         {
+-            while (TY_(IsWhite)(lexer->lexbuf[start+len-1]))
++            while (TY_(IsWhite)(lexer->lexbuf[start+len-1]) && (len > 0))
+                 --len;
+ 
+-            while (TY_(IsWhite)(lexer->lexbuf[start]) && start < len)
++            while (TY_(IsWhite)(lexer->lexbuf[start]) && (start < len) && 
(len > 0))
+             {
+                 ++start;
+                 --len;

diff --git a/dev-ruby/tidy-ext/tidy-ext-0.1.14-r3.ebuild 
b/dev-ruby/tidy-ext/tidy-ext-0.1.14-r3.ebuild
new file mode 100644
index 0000000..de43c73
--- /dev/null
+++ b/dev-ruby/tidy-ext/tidy-ext-0.1.14-r3.ebuild
@@ -0,0 +1,41 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+USE_RUBY="ruby20 ruby21 ruby22 ruby23"
+
+RUBY_FAKEGEM_DOCDIR="rdoc"
+
+RUBY_FAKEGEM_RECIPE_TEST="rspec"
+
+inherit ruby-fakegem eutils
+
+DESCRIPTION="W3C HTML Tidy library implemented as a Ruby extension"
+HOMEPAGE="https://github.com/carld/tidy";
+
+LICENSE="HTML-Tidy"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86"
+IUSE=""
+
+RUBY_PATCHES=( 11CVE-2015-5522.patch )
+
+all_ruby_prepare() {
+       mkdir lib || die
+
+       # Remove reference to rspec 1
+       sed -i -e '/spec/d' spec/spec_helper.rb || die
+
+       # Avoid spec that needs network connectivity.
+       rm spec/tidy/remote_uri_spec.rb || die
+}
+
+each_ruby_configure() {
+       ${RUBY} -Cext/tidy extconf.rb || die "Unable to configure extension."
+}
+
+each_ruby_compile() {
+       emake -Cext/tidy V=1
+       cp ext/tidy/tidy$(get_modname) lib/ || die "Unable to copy extension."
+}

Reply via email to