Browse code

Bug 1849840: [ CVE-2017-6181 ] ruby package, branch : 1.0

Change-Id: Ic0d78f6acd31725a2869e9147dbcc1b73ef601ef
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/3197
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Anish Swaminathan <anishs@vmware.com>

harishspqr authored on 2017/07/08 07:02:06
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,117 @@
0
+Index: b/regparse.c
1
+===================================================================
2
+--- a/regparse.c	(revision 57908)
3
+@@ -4570,11 +4570,11 @@ parse_char_class(Node** np, Node** asc_n https://github.com/ruby/ruby/blob/trunk/ruby_2_4/regparse.c#L4570
4
+   enum CCVALTYPE val_type, in_type;
5
+   int val_israw, in_israw;
6
+ 
7
++  *np = *asc_np = NULL_NODE;
8
+   env->parse_depth++;
9
+   if (env->parse_depth > ParseDepthLimit)
10
+     return ONIGERR_PARSE_DEPTH_LIMIT_OVER;
11
+   prev_cc = asc_prev_cc = (CClassNode* )NULL;
12
+-  *np = *asc_np = NULL_NODE;
13
+   r = fetch_token_in_cc(tok, src, end, env);
14
+   if (r == TK_CHAR && tok->u.c == '^' && tok->escaped == 0) {
15
+     neg = 1;
16
+Index: b/ext/-test-/regexp/init.c
17
+===================================================================
18
+--- a/ext/-test-/regexp/init.c	(revision 0)
19
+@@ -0,0 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/ext/-test-/regexp/init.c#L1
20
++#include "ruby.h"
21
++
22
++#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
23
++
24
++void
25
++Init_regexp(void)
26
++{
27
++    VALUE mBug = rb_define_module("Bug");
28
++    VALUE klass = rb_define_class_under(mBug, "Regexp", rb_cRegexp);
29
++    TEST_INIT_FUNCS(init);
30
++}
31
+
32
+Property changes on: ruby_2_4/ext/-test-/regexp/init.c
33
+___________________________________________________________________
34
+Added: svn:eol-style
35
+   + LF
36
+
37
+Index: b/ext/-test-/regexp/extconf.rb
38
+===================================================================
39
+--- a/ext/-test-/regexp/extconf.rb	(revision 0)
40
+@@ -0,0 +1,3 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/ext/-test-/regexp/extconf.rb#L1
41
++# frozen_string_literal: false
42
++require_relative "../auto_ext.rb"
43
++auto_ext
44
+
45
+Property changes on: ruby_2_4/ext/-test-/regexp/extconf.rb
46
+___________________________________________________________________
47
+Added: svn:eol-style
48
+   + LF
49
+
50
+Index: b/ext/-test-/regexp/parse_depth_limit.c
51
+===================================================================
52
+--- a/ext/-test-/regexp/parse_depth_limit.c	(revision 0)
53
+@@ -0,0 +1,23 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/ext/-test-/regexp/parse_depth_limit.c#L1
54
++#include <ruby.h>
55
++#include <ruby/onigmo.h>
56
++
57
++static VALUE
58
++get_parse_depth_limit(VALUE self)
59
++{
60
++    unsigned int depth = onig_get_parse_depth_limit();
61
++    return UINT2NUM(depth);
62
++}
63
++
64
++static VALUE
65
++set_parse_depth_limit(VALUE self, VALUE depth)
66
++{
67
++    onig_set_parse_depth_limit(NUM2UINT(depth));
68
++    return depth;
69
++}
70
++
71
++void
72
++Init_parse_depth_limit(VALUE klass)
73
++{
74
++    rb_define_singleton_method(klass, "parse_depth_limit", get_parse_depth_limit, 0);
75
++    rb_define_singleton_method(klass, "parse_depth_limit=", set_parse_depth_limit, 1);
76
++}
77
+
78
+Property changes on: ruby_2_4/ext/-test-/regexp/parse_depth_limit.c
79
+___________________________________________________________________
80
+Added: svn:eol-style
81
+   + LF
82
+
83
+Index: b/test/ruby/test_regexp.rb
84
+===================================================================
85
+--- a/test/ruby/test_regexp.rb	(revision 57908)
86
+@@ -1198,6 +1198,25 @@ class TestRegexp < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/ruby/test_regexp.rb#L1198
87
+     RUBY
88
+   end
89
+ 
90
++  def test_invalid_free_at_parse_depth_limit_over
91
++    assert_separately([], "#{<<-"begin;"}\n#{<<-"end;"}")
92
++    begin;
93
++      begin
94
++        require '-test-/regexp'
95
++      rescue LoadError
96
++      else
97
++        bug = '[ruby-core:79624] [Bug #13234]'
98
++        Bug::Regexp.parse_depth_limit = 10
99
++        src = "[" * 100
100
++        3.times do
101
++          assert_raise_with_message(RegexpError, /parse depth limit over/, bug) do
102
++            Regexp.new(src)
103
++          end
104
++        end
105
++      end
106
++    end;
107
++  end
108
++
109
+   # This assertion is for porting x2() tests in testpy.py of Onigmo.
110
+   def assert_match_at(re, str, positions, msg = nil)
111
+     re = Regexp.new(re) unless re.is_a?(Regexp)
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:    Ruby
2 2
 Name:       ruby
3 3
 Version:    2.4.0
4
-Release:    3%{?dist}
4
+Release:    4%{?dist}
5 5
 License:    BSDL
6 6
 URL:        https://www.ruby-lang.org/en/
7 7
 Group:      System Environment/Security
... ...
@@ -13,6 +13,7 @@ Patch0:     ruby-CVE-2017-9224.patch
13 13
 Patch1:     ruby-CVE-2017-9226.patch
14 14
 Patch2:     ruby-CVE-2017-9227.patch
15 15
 Patch3:     ruby-CVE-2017-9229.patch
16
+Patch4:	    ruby-CVE-2017-6181.patch
16 17
 BuildRequires:  openssl-devel
17 18
 BuildRequires:  ca-certificates
18 19
 BuildRequires:  readline-devel
... ...
@@ -30,6 +31,7 @@ This is useful for object-oriented scripting.
30 30
 %patch1 -p1
31 31
 %patch2 -p1
32 32
 %patch3 -p1
33
+%patch4 -p1
33 34
 %build
34 35
 ./configure \
35 36
     --prefix=%{_prefix}   \
... ...
@@ -57,6 +59,8 @@ rm -rf %{buildroot}/*
57 57
 %{_docdir}/%{name}-%{version}
58 58
 %{_mandir}/man1/*
59 59
 %changelog
60
+*   Fri Jul 07 2017 Harish Udaiya Kumar <hudaiyakumar@vmware.com> 2.4.0-4
61
+-   [security] ruby-CVE-2017-6181.patch
60 62
 *   Tue Jun 13 2017 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 2.4.0-3
61 63
 -   [security] CVE-2017-9224,CVE-2017-9225
62 64
 -   [security] CVE-2017-9227,CVE-2017-9229