diff options
author | Alexander Kanavin <alexander.kanavin@linux.intel.com> | 2018-01-12 18:20:01 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-01-14 22:10:54 +0000 |
commit | bbc0795ada93d943bf534289eaa7c07c5ffb7d44 (patch) | |
tree | a4799babf05503dd1ae12dbedb76725c7c82ff08 /meta/recipes-devtools | |
parent | e6aadcc2a04ae4e85b1cb00c5c9ce1c0f76ee871 (diff) | |
download | poky-bbc0795ada93d943bf534289eaa7c07c5ffb7d44.tar.gz |
ruby: update to 2.4.0
Existing version of ruby-native (2.2.5) was crashing on my machine (and others' too),
yet a functional ruby is necessary to upgrade webkit to a version that less vulnerable
to Spectre.
I've performed the update by copying the ruby recipe directory over from the current
pyro tree; if you want to see the list of specific commits, issue this command:
git log 99656fecf4fa6e24ba49ecb7f26f893e733818a0 meta/recipes-devtools/ruby
(up to commit e593d3aeb2ea5f08d6e0753133fe89e345b339e8)
(From OE-Core rev: 4734a4b41898e3df252b6234ed1270a915fd1f68)
Signed-off-by: Alexander Kanavin <alexander.kanavin@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools')
15 files changed, 516 insertions, 437 deletions
diff --git a/meta/recipes-devtools/ruby/ruby.inc b/meta/recipes-devtools/ruby/ruby.inc index fde67e9407..d71989889e 100644 --- a/meta/recipes-devtools/ruby/ruby.inc +++ b/meta/recipes-devtools/ruby/ruby.inc | |||
@@ -8,10 +8,10 @@ HOMEPAGE = "http://www.ruby-lang.org/" | |||
8 | SECTION = "devel/ruby" | 8 | SECTION = "devel/ruby" |
9 | LICENSE = "Ruby | BSD | GPLv2" | 9 | LICENSE = "Ruby | BSD | GPLv2" |
10 | LIC_FILES_CHKSUM = "\ | 10 | LIC_FILES_CHKSUM = "\ |
11 | file://COPYING;md5=837b32593517ae48b9c3b5c87a5d288c \ | 11 | file://COPYING;md5=8a960b08d972f43f91ae84a6f00dcbfb \ |
12 | file://BSDL;md5=19aaf65c88a40b508d17ae4be539c4b5\ | 12 | file://BSDL;md5=19aaf65c88a40b508d17ae4be539c4b5\ |
13 | file://GPL;md5=b234ee4d69f5fce4486a80fdaf4a4263\ | 13 | file://GPL;md5=b234ee4d69f5fce4486a80fdaf4a4263\ |
14 | file://LEGAL;md5=c440adb575ba4e6e2344c2630b6a5584\ | 14 | file://LEGAL;md5=daf349ad59dd19bd8c919171bff3c5d6 \ |
15 | " | 15 | " |
16 | 16 | ||
17 | DEPENDS = "ruby-native zlib openssl tcl libyaml db gdbm readline" | 17 | DEPENDS = "ruby-native zlib openssl tcl libyaml db gdbm readline" |
@@ -22,6 +22,7 @@ SRC_URI = "http://cache.ruby-lang.org/pub/ruby/${SHRT_VER}/ruby-${PV}.tar.gz \ | |||
22 | file://extmk.patch \ | 22 | file://extmk.patch \ |
23 | file://0002-Obey-LDFLAGS-for-the-link-of-libruby.patch \ | 23 | file://0002-Obey-LDFLAGS-for-the-link-of-libruby.patch \ |
24 | " | 24 | " |
25 | UPSTREAM_CHECK_URI = "https://www.ruby-lang.org/en/downloads/" | ||
25 | 26 | ||
26 | inherit autotools | 27 | inherit autotools |
27 | 28 | ||
diff --git a/meta/recipes-devtools/ruby/ruby/CVE-2016-7798.patch b/meta/recipes-devtools/ruby/ruby/CVE-2016-7798.patch deleted file mode 100644 index 2b8772ba41..0000000000 --- a/meta/recipes-devtools/ruby/ruby/CVE-2016-7798.patch +++ /dev/null | |||
@@ -1,164 +0,0 @@ | |||
1 | cipher: don't set dummy encryption key in Cipher#initialize | ||
2 | Remove the encryption key initialization from Cipher#initialize. This | ||
3 | is effectively a revert of r32723 ("Avoid possible SEGV from AES | ||
4 | encryption/decryption", 2011-07-28). | ||
5 | |||
6 | r32723, which added the key initialization, was a workaround for | ||
7 | Ruby Bug #2768. For some certain ciphers, calling EVP_CipherUpdate() | ||
8 | before setting an encryption key caused segfault. It was not a problem | ||
9 | until OpenSSL implemented GCM mode - the encryption key could be | ||
10 | overridden by repeated calls of EVP_CipherInit_ex(). But, it is not the | ||
11 | case for AES-GCM ciphers. Setting a key, an IV, a key, in this order | ||
12 | causes the IV to be reset to an all-zero IV. | ||
13 | |||
14 | The problem of Bug #2768 persists on the current versions of OpenSSL. | ||
15 | So, make Cipher#update raise an exception if a key is not yet set by the | ||
16 | user. Since encrypting or decrypting without key does not make any | ||
17 | sense, this should not break existing applications. | ||
18 | |||
19 | Users can still call Cipher#key= and Cipher#iv= multiple times with | ||
20 | their own responsibility. | ||
21 | |||
22 | Reference: https://bugs.ruby-lang.org/issues/2768 | ||
23 | Reference: https://bugs.ruby-lang.org/issues/8221 | ||
24 | |||
25 | Upstream-Status: Backport | ||
26 | CVE: CVE-2016-7798 | ||
27 | |||
28 | Signed-off-by: Thiruvadi Rajaraman <trajaraman@mvista.com> | ||
29 | |||
30 | Index: ruby-2.2.2/ext/openssl/ossl_cipher.c | ||
31 | =================================================================== | ||
32 | --- ruby-2.2.2.orig/ext/openssl/ossl_cipher.c | ||
33 | +++ ruby-2.2.2/ext/openssl/ossl_cipher.c | ||
34 | @@ -35,6 +35,7 @@ | ||
35 | */ | ||
36 | VALUE cCipher; | ||
37 | VALUE eCipherError; | ||
38 | +static ID id_key_set; | ||
39 | |||
40 | static VALUE ossl_cipher_alloc(VALUE klass); | ||
41 | static void ossl_cipher_free(void *ptr); | ||
42 | @@ -119,7 +120,6 @@ ossl_cipher_initialize(VALUE self, VALUE | ||
43 | EVP_CIPHER_CTX *ctx; | ||
44 | const EVP_CIPHER *cipher; | ||
45 | char *name; | ||
46 | - unsigned char key[EVP_MAX_KEY_LENGTH]; | ||
47 | |||
48 | name = StringValuePtr(str); | ||
49 | GetCipherInit(self, ctx); | ||
50 | @@ -131,14 +131,7 @@ ossl_cipher_initialize(VALUE self, VALUE | ||
51 | if (!(cipher = EVP_get_cipherbyname(name))) { | ||
52 | ossl_raise(rb_eRuntimeError, "unsupported cipher algorithm (%s)", name); | ||
53 | } | ||
54 | - /* | ||
55 | - * The EVP which has EVP_CIPH_RAND_KEY flag (such as DES3) allows | ||
56 | - * uninitialized key, but other EVPs (such as AES) does not allow it. | ||
57 | - * Calling EVP_CipherUpdate() without initializing key causes SEGV so we | ||
58 | - * set the data filled with "\0" as the key by default. | ||
59 | - */ | ||
60 | - memset(key, 0, EVP_MAX_KEY_LENGTH); | ||
61 | - if (EVP_CipherInit_ex(ctx, cipher, NULL, key, NULL, -1) != 1) | ||
62 | + if (EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, -1) != 1) | ||
63 | ossl_raise(eCipherError, NULL); | ||
64 | |||
65 | return self; | ||
66 | @@ -256,6 +249,8 @@ ossl_cipher_init(int argc, VALUE *argv, | ||
67 | if (EVP_CipherInit_ex(ctx, NULL, NULL, p_key, p_iv, mode) != 1) { | ||
68 | ossl_raise(eCipherError, NULL); | ||
69 | } | ||
70 | + if (p_key) | ||
71 | + rb_ivar_set(self, id_key_set, Qtrue); | ||
72 | |||
73 | return self; | ||
74 | } | ||
75 | @@ -343,6 +338,8 @@ ossl_cipher_pkcs5_keyivgen(int argc, VAL | ||
76 | OPENSSL_cleanse(key, sizeof key); | ||
77 | OPENSSL_cleanse(iv, sizeof iv); | ||
78 | |||
79 | + rb_ivar_set(self, id_key_set, Qtrue); | ||
80 | + | ||
81 | return Qnil; | ||
82 | } | ||
83 | |||
84 | @@ -396,6 +393,9 @@ ossl_cipher_update(int argc, VALUE *argv | ||
85 | |||
86 | rb_scan_args(argc, argv, "11", &data, &str); | ||
87 | |||
88 | + if (!RTEST(rb_attr_get(self, id_key_set))) | ||
89 | + ossl_raise(eCipherError, "key not set"); | ||
90 | + | ||
91 | StringValue(data); | ||
92 | in = (unsigned char *)RSTRING_PTR(data); | ||
93 | if ((in_len = RSTRING_LEN(data)) == 0) | ||
94 | @@ -495,6 +495,8 @@ ossl_cipher_set_key(VALUE self, VALUE ke | ||
95 | if (EVP_CipherInit_ex(ctx, NULL, NULL, (unsigned char *)RSTRING_PTR(key), NULL, -1) != 1) | ||
96 | ossl_raise(eCipherError, NULL); | ||
97 | |||
98 | + rb_ivar_set(self, id_key_set, Qtrue); | ||
99 | + | ||
100 | return key; | ||
101 | } | ||
102 | |||
103 | @@ -1013,5 +1015,7 @@ Init_ossl_cipher(void) | ||
104 | rb_define_method(cCipher, "iv_len", ossl_cipher_iv_length, 0); | ||
105 | rb_define_method(cCipher, "block_size", ossl_cipher_block_size, 0); | ||
106 | rb_define_method(cCipher, "padding=", ossl_cipher_set_padding, 1); | ||
107 | + | ||
108 | + id_key_set = rb_intern_const("key_set"); | ||
109 | } | ||
110 | |||
111 | Index: ruby-2.2.2/test/openssl/test_cipher.rb | ||
112 | =================================================================== | ||
113 | --- ruby-2.2.2.orig/test/openssl/test_cipher.rb | ||
114 | +++ ruby-2.2.2/test/openssl/test_cipher.rb | ||
115 | @@ -80,6 +80,7 @@ class OpenSSL::TestCipher < Test::Unit:: | ||
116 | |||
117 | def test_empty_data | ||
118 | @c1.encrypt | ||
119 | + @c1.random_key | ||
120 | assert_raise(ArgumentError){ @c1.update("") } | ||
121 | end | ||
122 | |||
123 | @@ -127,13 +128,10 @@ class OpenSSL::TestCipher < Test::Unit:: | ||
124 | assert_equal(pt, c2.update(ct) + c2.final) | ||
125 | } | ||
126 | end | ||
127 | - | ||
128 | - def test_AES_crush | ||
129 | - 500.times do | ||
130 | - assert_nothing_raised("[Bug #2768]") do | ||
131 | - # it caused OpenSSL SEGV by uninitialized key | ||
132 | - OpenSSL::Cipher::AES128.new("ECB").update "." * 17 | ||
133 | - end | ||
134 | + def test_update_raise_if_key_not_set | ||
135 | + assert_raise(OpenSSL::Cipher::CipherError) do | ||
136 | + # it caused OpenSSL SEGV by uninitialized key [Bug #2768] | ||
137 | + OpenSSL::Cipher::AES128.new("ECB").update "." * 17 | ||
138 | end | ||
139 | end | ||
140 | end | ||
141 | @@ -236,6 +234,23 @@ class OpenSSL::TestCipher < Test::Unit:: | ||
142 | end | ||
143 | |||
144 | end | ||
145 | + def test_aes_gcm_key_iv_order_issue | ||
146 | + pt = "[ruby/openssl#49]" | ||
147 | + cipher = OpenSSL::Cipher.new("aes-128-gcm").encrypt | ||
148 | + cipher.key = "x" * 16 | ||
149 | + cipher.iv = "a" * 12 | ||
150 | + ct1 = cipher.update(pt) << cipher.final | ||
151 | + tag1 = cipher.auth_tag | ||
152 | + | ||
153 | + cipher = OpenSSL::Cipher.new("aes-128-gcm").encrypt | ||
154 | + cipher.iv = "a" * 12 | ||
155 | + cipher.key = "x" * 16 | ||
156 | + ct2 = cipher.update(pt) << cipher.final | ||
157 | + tag2 = cipher.auth_tag | ||
158 | + | ||
159 | + assert_equal ct1, ct2 | ||
160 | + assert_equal tag1, tag2 | ||
161 | + end if has_cipher?("aes-128-gcm") | ||
162 | |||
163 | private | ||
164 | |||
diff --git a/meta/recipes-devtools/ruby/ruby/CVE-2017-14033.patch b/meta/recipes-devtools/ruby/ruby/CVE-2017-14033.patch deleted file mode 100644 index cbcd18c788..0000000000 --- a/meta/recipes-devtools/ruby/ruby/CVE-2017-14033.patch +++ /dev/null | |||
@@ -1,89 +0,0 @@ | |||
1 | From 1648afef33c1d97fb203c82291b8a61269e85d3b Mon Sep 17 00:00:00 2001 | ||
2 | From: Kazuki Yamaguchi <k@rhe.jp> | ||
3 | Date: Mon, 19 Sep 2016 15:38:44 +0900 | ||
4 | Subject: [PATCH] asn1: fix out-of-bounds read in decoding constructed objects | ||
5 | |||
6 | OpenSSL::ASN1.{decode,decode_all,traverse} have a bug of out-of-bounds | ||
7 | read. int_ossl_asn1_decode0_cons() does not give the correct available | ||
8 | length to ossl_asn1_decode() when decoding the inner components of a | ||
9 | constructed object. This can cause out-of-bounds read if a crafted input | ||
10 | given. | ||
11 | |||
12 | Reference: https://hackerone.com/reports/170316 | ||
13 | |||
14 | Upstream-Status: Backport | ||
15 | CVE: CVE-2017-14033 | ||
16 | |||
17 | Signed-off-by: Rajkumar Veer<rveer@mvista.com> | ||
18 | --- | ||
19 | ext/openssl/ossl_asn1.c | 13 ++++++------- | ||
20 | test/test_asn1.rb | 23 +++++++++++++++++++++++ | ||
21 | 2 files changed, 29 insertions(+), 7 deletions(-) | ||
22 | --- a/ext/openssl/ossl_asn1.c | ||
23 | +++ b/ext/openssl/ossl_asn1.c | ||
24 | @@ -871,19 +871,18 @@ | ||
25 | { | ||
26 | VALUE value, asn1data, ary; | ||
27 | int infinite; | ||
28 | - long off = *offset; | ||
29 | + long available_len, off = *offset; | ||
30 | |||
31 | infinite = (j == 0x21); | ||
32 | ary = rb_ary_new(); | ||
33 | |||
34 | - while (length > 0 || infinite) { | ||
35 | + available_len = infinite ? max_len : length; | ||
36 | + while (available_len > 0 ) { | ||
37 | long inner_read = 0; | ||
38 | - value = ossl_asn1_decode0(pp, max_len, &off, depth + 1, yield, &inner_read); | ||
39 | + value = ossl_asn1_decode0(pp, available_len, &off, depth + 1, yield, &inner_read); | ||
40 | *num_read += inner_read; | ||
41 | - max_len -= inner_read; | ||
42 | + available_len -= inner_read; | ||
43 | rb_ary_push(ary, value); | ||
44 | - if (length > 0) | ||
45 | - length -= inner_read; | ||
46 | |||
47 | if (infinite && | ||
48 | NUM2INT(ossl_asn1_get_tag(value)) == V_ASN1_EOC && | ||
49 | @@ -974,7 +973,7 @@ | ||
50 | if(j & V_ASN1_CONSTRUCTED) { | ||
51 | *pp += hlen; | ||
52 | off += hlen; | ||
53 | - asn1data = int_ossl_asn1_decode0_cons(pp, length, len, &off, depth, yield, j, tag, tag_class, &inner_read); | ||
54 | + asn1data = int_ossl_asn1_decode0_cons(pp, length - hlen, len, &off, depth, yield, j, tag, tag_class, &inner_read); | ||
55 | inner_read += hlen; | ||
56 | } | ||
57 | else { | ||
58 | --- a/test/openssl/test_asn1.rb | ||
59 | +++ b/test/openssl/test_asn1.rb | ||
60 | @@ -595,6 +595,29 @@ | ||
61 | assert_equal(false, asn1.value[3].infinite_length) | ||
62 | end | ||
63 | |||
64 | + def test_decode_constructed_overread | ||
65 | + test = %w{ 31 06 31 02 30 02 05 00 } | ||
66 | + # ^ <- invalid | ||
67 | + raw = [test.join].pack("H*") | ||
68 | + ret = [] | ||
69 | + assert_raise(OpenSSL::ASN1::ASN1Error) { | ||
70 | + OpenSSL::ASN1.traverse(raw) { |x| ret << x } | ||
71 | + } | ||
72 | + assert_equal 2, ret.size | ||
73 | + assert_equal 17, ret[0][6] | ||
74 | + assert_equal 17, ret[1][6] | ||
75 | + | ||
76 | + test = %w{ 31 80 30 03 00 00 } | ||
77 | + # ^ <- invalid | ||
78 | + raw = [test.join].pack("H*") | ||
79 | + ret = [] | ||
80 | + assert_raise(OpenSSL::ASN1::ASN1Error) { | ||
81 | + OpenSSL::ASN1.traverse(raw) { |x| ret << x } | ||
82 | + } | ||
83 | + assert_equal 1, ret.size | ||
84 | + assert_equal 17, ret[0][6] | ||
85 | + end | ||
86 | + | ||
87 | private | ||
88 | |||
89 | def assert_universal(tag, asn1) | ||
diff --git a/meta/recipes-devtools/ruby/ruby/CVE-2017-14064.patch b/meta/recipes-devtools/ruby/ruby/CVE-2017-14064.patch index 073d214d88..700d1bc58e 100644 --- a/meta/recipes-devtools/ruby/ruby/CVE-2017-14064.patch +++ b/meta/recipes-devtools/ruby/ruby/CVE-2017-14064.patch | |||
@@ -1,19 +1,54 @@ | |||
1 | From 8f782fd8e181d9cfe9387ded43a5ca9692266b85 Mon Sep 17 00:00:00 2001 | 1 | From d86d283fcb35d1442a121b92030884523908a331 Mon Sep 17 00:00:00 2001 |
2 | From: Florian Frank <flori@ping.de> | 2 | From: nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> |
3 | Date: Thu, 2 Mar 2017 12:12:33 +0100 | 3 | Date: Sat, 22 Apr 2017 07:29:01 +0000 |
4 | Subject: [PATCH] Fix arbitrary heap exposure problem | 4 | Subject: [PATCH] merge revision(s) 58323,58324: |
5 | |||
6 | Merge json-2.0.4. | ||
7 | |||
8 | * https://github.com/flori/json/releases/tag/v2.0.4 | ||
9 | * https://github.com/flori/json/blob/09fabeb03e73ed88dc8ce8f19d76ac59e51dae20/CHANGES.md#2017-03-23-204 | ||
10 | Use `assert_raise` instead of `assert_raises`. | ||
11 | |||
12 | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@58445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e | ||
5 | 13 | ||
6 | Upstream-Status: Backport | 14 | Upstream-Status: Backport |
7 | CVE: CVE-2017-14064 | 15 | CVE: CVE-2017-14064 |
8 | 16 | ||
9 | Signed-off-by: Rajkumar Veer<rveer@mvista.com> | 17 | Signed-off-by: Armin Kuster <akuster@mvisa.com> |
18 | |||
10 | --- | 19 | --- |
11 | ext/json/ext/generator/generator.c | 12 ++++++------ | 20 | ext/json/fbuffer/fbuffer.h | 3 --- |
12 | ext/json/ext/generator/generator.h | 1 - | 21 | ext/json/generator/generator.c | 12 +++++----- |
13 | 2 files changed, 6 insertions(+), 7 deletions(-) | 22 | ext/json/generator/generator.h | 1 - |
14 | --- a/ext/json/generator/generator.c | 23 | ext/json/json.gemspec | Bin 5473 -> 5474 bytes |
15 | +++ b/ext/json/generator/generator.c | 24 | ext/json/lib/json/version.rb | 2 +- |
16 | @@ -301,7 +301,7 @@ | 25 | ext/json/parser/parser.c | 48 +++++++++++++++++++++++---------------- |
26 | ext/json/parser/parser.rl | 14 +++++++++--- | ||
27 | test/json/json_encoding_test.rb | 2 ++ | ||
28 | test/json/json_generator_test.rb | 0 | ||
29 | version.h | 2 +- | ||
30 | 10 files changed, 49 insertions(+), 35 deletions(-) | ||
31 | mode change 100755 => 100644 test/json/json_generator_test.rb | ||
32 | |||
33 | Index: ruby-2.4.0/ext/json/fbuffer/fbuffer.h | ||
34 | =================================================================== | ||
35 | --- ruby-2.4.0.orig/ext/json/fbuffer/fbuffer.h | ||
36 | +++ ruby-2.4.0/ext/json/fbuffer/fbuffer.h | ||
37 | @@ -12,9 +12,6 @@ | ||
38 | #define RFLOAT_VALUE(val) (RFLOAT(val)->value) | ||
39 | #endif | ||
40 | |||
41 | -#ifndef RARRAY_PTR | ||
42 | -#define RARRAY_PTR(ARRAY) RARRAY(ARRAY)->ptr | ||
43 | -#endif | ||
44 | #ifndef RARRAY_LEN | ||
45 | #define RARRAY_LEN(ARRAY) RARRAY(ARRAY)->len | ||
46 | #endif | ||
47 | Index: ruby-2.4.0/ext/json/generator/generator.c | ||
48 | =================================================================== | ||
49 | --- ruby-2.4.0.orig/ext/json/generator/generator.c | ||
50 | +++ ruby-2.4.0/ext/json/generator/generator.c | ||
51 | @@ -308,7 +308,7 @@ static char *fstrndup(const char *ptr, u | ||
17 | char *result; | 52 | char *result; |
18 | if (len <= 0) return NULL; | 53 | if (len <= 0) return NULL; |
19 | result = ALLOC_N(char, len); | 54 | result = ALLOC_N(char, len); |
@@ -22,7 +57,7 @@ Signed-off-by: Rajkumar Veer<rveer@mvista.com> | |||
22 | return result; | 57 | return result; |
23 | } | 58 | } |
24 | 59 | ||
25 | @@ -1055,7 +1055,7 @@ | 60 | @@ -1062,7 +1062,7 @@ static VALUE cState_indent_set(VALUE sel |
26 | } | 61 | } |
27 | } else { | 62 | } else { |
28 | if (state->indent) ruby_xfree(state->indent); | 63 | if (state->indent) ruby_xfree(state->indent); |
@@ -31,7 +66,7 @@ Signed-off-by: Rajkumar Veer<rveer@mvista.com> | |||
31 | state->indent_len = len; | 66 | state->indent_len = len; |
32 | } | 67 | } |
33 | return Qnil; | 68 | return Qnil; |
34 | @@ -1093,7 +1093,7 @@ | 69 | @@ -1100,7 +1100,7 @@ static VALUE cState_space_set(VALUE self |
35 | } | 70 | } |
36 | } else { | 71 | } else { |
37 | if (state->space) ruby_xfree(state->space); | 72 | if (state->space) ruby_xfree(state->space); |
@@ -40,7 +75,7 @@ Signed-off-by: Rajkumar Veer<rveer@mvista.com> | |||
40 | state->space_len = len; | 75 | state->space_len = len; |
41 | } | 76 | } |
42 | return Qnil; | 77 | return Qnil; |
43 | @@ -1129,7 +1129,7 @@ | 78 | @@ -1136,7 +1136,7 @@ static VALUE cState_space_before_set(VAL |
44 | } | 79 | } |
45 | } else { | 80 | } else { |
46 | if (state->space_before) ruby_xfree(state->space_before); | 81 | if (state->space_before) ruby_xfree(state->space_before); |
@@ -49,7 +84,7 @@ Signed-off-by: Rajkumar Veer<rveer@mvista.com> | |||
49 | state->space_before_len = len; | 84 | state->space_before_len = len; |
50 | } | 85 | } |
51 | return Qnil; | 86 | return Qnil; |
52 | @@ -1166,7 +1166,7 @@ | 87 | @@ -1173,7 +1173,7 @@ static VALUE cState_object_nl_set(VALUE |
53 | } | 88 | } |
54 | } else { | 89 | } else { |
55 | if (state->object_nl) ruby_xfree(state->object_nl); | 90 | if (state->object_nl) ruby_xfree(state->object_nl); |
@@ -58,17 +93,19 @@ Signed-off-by: Rajkumar Veer<rveer@mvista.com> | |||
58 | state->object_nl_len = len; | 93 | state->object_nl_len = len; |
59 | } | 94 | } |
60 | return Qnil; | 95 | return Qnil; |
61 | @@ -1201,7 +1201,7 @@ | 96 | @@ -1208,7 +1208,7 @@ static VALUE cState_array_nl_set(VALUE s |
62 | } | 97 | } |
63 | } else { | 98 | } else { |
64 | if (state->array_nl) ruby_xfree(state->array_nl); | 99 | if (state->array_nl) ruby_xfree(state->array_nl); |
65 | - state->array_nl = strdup(RSTRING_PTR(array_nl)); | 100 | - state->array_nl = strdup(RSTRING_PTR(array_nl)); |
66 | + state->array_nl = fstrndup(RSTRING_PTR(array_nl), len); | 101 | + state->array_nl = fstrndup(RSTRING_PTR(array_nl), len); |
67 | state->array_nl_len = len; | 102 | state->array_nl_len = len; |
68 | } | 103 | } |
69 | return Qnil; | 104 | return Qnil; |
70 | --- a/ext/json/generator/generator.h | 105 | Index: ruby-2.4.0/ext/json/generator/generator.h |
71 | +++ b/ext/json/generator/generator.h | 106 | =================================================================== |
107 | --- ruby-2.4.0.orig/ext/json/generator/generator.h | ||
108 | +++ ruby-2.4.0/ext/json/generator/generator.h | ||
72 | @@ -1,7 +1,6 @@ | 109 | @@ -1,7 +1,6 @@ |
73 | #ifndef _GENERATOR_H_ | 110 | #ifndef _GENERATOR_H_ |
74 | #define _GENERATOR_H_ | 111 | #define _GENERATOR_H_ |
@@ -77,3 +114,240 @@ Signed-off-by: Rajkumar Veer<rveer@mvista.com> | |||
77 | #include <math.h> | 114 | #include <math.h> |
78 | #include <ctype.h> | 115 | #include <ctype.h> |
79 | 116 | ||
117 | Index: ruby-2.4.0/ext/json/lib/json/version.rb | ||
118 | =================================================================== | ||
119 | --- ruby-2.4.0.orig/ext/json/lib/json/version.rb | ||
120 | +++ ruby-2.4.0/ext/json/lib/json/version.rb | ||
121 | @@ -1,7 +1,7 @@ | ||
122 | # frozen_string_literal: false | ||
123 | module JSON | ||
124 | # JSON version | ||
125 | - VERSION = '2.0.2' | ||
126 | + VERSION = '2.0.4' | ||
127 | VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc: | ||
128 | VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc: | ||
129 | VERSION_MINOR = VERSION_ARRAY[1] # :nodoc: | ||
130 | Index: ruby-2.4.0/ext/json/parser/parser.c | ||
131 | =================================================================== | ||
132 | --- ruby-2.4.0.orig/ext/json/parser/parser.c | ||
133 | +++ ruby-2.4.0/ext/json/parser/parser.c | ||
134 | @@ -1435,13 +1435,21 @@ static VALUE json_string_unescape(VALUE | ||
135 | break; | ||
136 | case 'u': | ||
137 | if (pe > stringEnd - 4) { | ||
138 | - return Qnil; | ||
139 | + rb_enc_raise( | ||
140 | + EXC_ENCODING eParserError, | ||
141 | + "%u: incomplete unicode character escape sequence at '%s'", __LINE__, p | ||
142 | + ); | ||
143 | } else { | ||
144 | UTF32 ch = unescape_unicode((unsigned char *) ++pe); | ||
145 | pe += 3; | ||
146 | if (UNI_SUR_HIGH_START == (ch & 0xFC00)) { | ||
147 | pe++; | ||
148 | - if (pe > stringEnd - 6) return Qnil; | ||
149 | + if (pe > stringEnd - 6) { | ||
150 | + rb_enc_raise( | ||
151 | + EXC_ENCODING eParserError, | ||
152 | + "%u: incomplete surrogate pair at '%s'", __LINE__, p | ||
153 | + ); | ||
154 | + } | ||
155 | if (pe[0] == '\\' && pe[1] == 'u') { | ||
156 | UTF32 sur = unescape_unicode((unsigned char *) pe + 2); | ||
157 | ch = (((ch & 0x3F) << 10) | ((((ch >> 6) & 0xF) + 1) << 16) | ||
158 | @@ -1471,7 +1479,7 @@ static VALUE json_string_unescape(VALUE | ||
159 | } | ||
160 | |||
161 | |||
162 | -#line 1475 "parser.c" | ||
163 | +#line 1483 "parser.c" | ||
164 | enum {JSON_string_start = 1}; | ||
165 | enum {JSON_string_first_final = 8}; | ||
166 | enum {JSON_string_error = 0}; | ||
167 | @@ -1479,7 +1487,7 @@ enum {JSON_string_error = 0}; | ||
168 | enum {JSON_string_en_main = 1}; | ||
169 | |||
170 | |||
171 | -#line 504 "parser.rl" | ||
172 | +#line 512 "parser.rl" | ||
173 | |||
174 | |||
175 | static int | ||
176 | @@ -1501,15 +1509,15 @@ static char *JSON_parse_string(JSON_Pars | ||
177 | |||
178 | *result = rb_str_buf_new(0); | ||
179 | |||
180 | -#line 1505 "parser.c" | ||
181 | +#line 1513 "parser.c" | ||
182 | { | ||
183 | cs = JSON_string_start; | ||
184 | } | ||
185 | |||
186 | -#line 525 "parser.rl" | ||
187 | +#line 533 "parser.rl" | ||
188 | json->memo = p; | ||
189 | |||
190 | -#line 1513 "parser.c" | ||
191 | +#line 1521 "parser.c" | ||
192 | { | ||
193 | if ( p == pe ) | ||
194 | goto _test_eof; | ||
195 | @@ -1534,7 +1542,7 @@ case 2: | ||
196 | goto st0; | ||
197 | goto st2; | ||
198 | tr2: | ||
199 | -#line 490 "parser.rl" | ||
200 | +#line 498 "parser.rl" | ||
201 | { | ||
202 | *result = json_string_unescape(*result, json->memo + 1, p); | ||
203 | if (NIL_P(*result)) { | ||
204 | @@ -1545,14 +1553,14 @@ tr2: | ||
205 | {p = (( p + 1))-1;} | ||
206 | } | ||
207 | } | ||
208 | -#line 501 "parser.rl" | ||
209 | +#line 509 "parser.rl" | ||
210 | { p--; {p++; cs = 8; goto _out;} } | ||
211 | goto st8; | ||
212 | st8: | ||
213 | if ( ++p == pe ) | ||
214 | goto _test_eof8; | ||
215 | case 8: | ||
216 | -#line 1556 "parser.c" | ||
217 | +#line 1564 "parser.c" | ||
218 | goto st0; | ||
219 | st3: | ||
220 | if ( ++p == pe ) | ||
221 | @@ -1628,7 +1636,7 @@ case 7: | ||
222 | _out: {} | ||
223 | } | ||
224 | |||
225 | -#line 527 "parser.rl" | ||
226 | +#line 535 "parser.rl" | ||
227 | |||
228 | if (json->create_additions && RTEST(match_string = json->match_string)) { | ||
229 | VALUE klass; | ||
230 | @@ -1675,7 +1683,7 @@ static VALUE convert_encoding(VALUE sour | ||
231 | } | ||
232 | FORCE_UTF8(source); | ||
233 | } else { | ||
234 | - source = rb_str_conv_enc(source, NULL, rb_utf8_encoding()); | ||
235 | + source = rb_str_conv_enc(source, rb_enc_get(source), rb_utf8_encoding()); | ||
236 | } | ||
237 | #endif | ||
238 | return source; | ||
239 | @@ -1808,7 +1816,7 @@ static VALUE cParser_initialize(int argc | ||
240 | } | ||
241 | |||
242 | |||
243 | -#line 1812 "parser.c" | ||
244 | +#line 1820 "parser.c" | ||
245 | enum {JSON_start = 1}; | ||
246 | enum {JSON_first_final = 10}; | ||
247 | enum {JSON_error = 0}; | ||
248 | @@ -1816,7 +1824,7 @@ enum {JSON_error = 0}; | ||
249 | enum {JSON_en_main = 1}; | ||
250 | |||
251 | |||
252 | -#line 720 "parser.rl" | ||
253 | +#line 728 "parser.rl" | ||
254 | |||
255 | |||
256 | /* | ||
257 | @@ -1833,16 +1841,16 @@ static VALUE cParser_parse(VALUE self) | ||
258 | GET_PARSER; | ||
259 | |||
260 | |||
261 | -#line 1837 "parser.c" | ||
262 | +#line 1845 "parser.c" | ||
263 | { | ||
264 | cs = JSON_start; | ||
265 | } | ||
266 | |||
267 | -#line 736 "parser.rl" | ||
268 | +#line 744 "parser.rl" | ||
269 | p = json->source; | ||
270 | pe = p + json->len; | ||
271 | |||
272 | -#line 1846 "parser.c" | ||
273 | +#line 1854 "parser.c" | ||
274 | { | ||
275 | if ( p == pe ) | ||
276 | goto _test_eof; | ||
277 | @@ -1876,7 +1884,7 @@ st0: | ||
278 | cs = 0; | ||
279 | goto _out; | ||
280 | tr2: | ||
281 | -#line 712 "parser.rl" | ||
282 | +#line 720 "parser.rl" | ||
283 | { | ||
284 | char *np = JSON_parse_value(json, p, pe, &result, 0); | ||
285 | if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;} | ||
286 | @@ -1886,7 +1894,7 @@ st10: | ||
287 | if ( ++p == pe ) | ||
288 | goto _test_eof10; | ||
289 | case 10: | ||
290 | -#line 1890 "parser.c" | ||
291 | +#line 1898 "parser.c" | ||
292 | switch( (*p) ) { | ||
293 | case 13: goto st10; | ||
294 | case 32: goto st10; | ||
295 | @@ -1975,7 +1983,7 @@ case 9: | ||
296 | _out: {} | ||
297 | } | ||
298 | |||
299 | -#line 739 "parser.rl" | ||
300 | +#line 747 "parser.rl" | ||
301 | |||
302 | if (cs >= JSON_first_final && p == pe) { | ||
303 | return result; | ||
304 | Index: ruby-2.4.0/ext/json/parser/parser.rl | ||
305 | =================================================================== | ||
306 | --- ruby-2.4.0.orig/ext/json/parser/parser.rl | ||
307 | +++ ruby-2.4.0/ext/json/parser/parser.rl | ||
308 | @@ -446,13 +446,21 @@ static VALUE json_string_unescape(VALUE | ||
309 | break; | ||
310 | case 'u': | ||
311 | if (pe > stringEnd - 4) { | ||
312 | - return Qnil; | ||
313 | + rb_enc_raise( | ||
314 | + EXC_ENCODING eParserError, | ||
315 | + "%u: incomplete unicode character escape sequence at '%s'", __LINE__, p | ||
316 | + ); | ||
317 | } else { | ||
318 | UTF32 ch = unescape_unicode((unsigned char *) ++pe); | ||
319 | pe += 3; | ||
320 | if (UNI_SUR_HIGH_START == (ch & 0xFC00)) { | ||
321 | pe++; | ||
322 | - if (pe > stringEnd - 6) return Qnil; | ||
323 | + if (pe > stringEnd - 6) { | ||
324 | + rb_enc_raise( | ||
325 | + EXC_ENCODING eParserError, | ||
326 | + "%u: incomplete surrogate pair at '%s'", __LINE__, p | ||
327 | + ); | ||
328 | + } | ||
329 | if (pe[0] == '\\' && pe[1] == 'u') { | ||
330 | UTF32 sur = unescape_unicode((unsigned char *) pe + 2); | ||
331 | ch = (((ch & 0x3F) << 10) | ((((ch >> 6) & 0xF) + 1) << 16) | ||
332 | @@ -570,7 +578,7 @@ static VALUE convert_encoding(VALUE sour | ||
333 | } | ||
334 | FORCE_UTF8(source); | ||
335 | } else { | ||
336 | - source = rb_str_conv_enc(source, NULL, rb_utf8_encoding()); | ||
337 | + source = rb_str_conv_enc(source, rb_enc_get(source), rb_utf8_encoding()); | ||
338 | } | ||
339 | #endif | ||
340 | return source; | ||
341 | Index: ruby-2.4.0/test/json/json_encoding_test.rb | ||
342 | =================================================================== | ||
343 | --- ruby-2.4.0.orig/test/json/json_encoding_test.rb | ||
344 | +++ ruby-2.4.0/test/json/json_encoding_test.rb | ||
345 | @@ -79,6 +79,8 @@ class JSONEncodingTest < Test::Unit::Tes | ||
346 | json = '["\ud840\udc01"]' | ||
347 | assert_equal json, generate(utf8, :ascii_only => true) | ||
348 | assert_equal utf8, parse(json) | ||
349 | + assert_raise(JSON::ParserError) { parse('"\u"') } | ||
350 | + assert_raise(JSON::ParserError) { parse('"\ud800"') } | ||
351 | end | ||
352 | |||
353 | def test_chars | ||
diff --git a/meta/recipes-devtools/ruby/ruby/CVE-2017-9226.patch b/meta/recipes-devtools/ruby/ruby/CVE-2017-9226.patch deleted file mode 100644 index fc783e8a15..0000000000 --- a/meta/recipes-devtools/ruby/ruby/CVE-2017-9226.patch +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | commit f015fbdd95f76438cd86366467bb2b39870dd7c6 | ||
2 | Author: K.Kosako <kosako@sofnec.co.jp> | ||
3 | Date: Fri May 19 15:44:47 2017 +0900 | ||
4 | |||
5 | fix #55 : Byte value expressed in octal must be smaller than 256 | ||
6 | |||
7 | Upstream-Status: Backport | ||
8 | |||
9 | CVE: CVE-2017-9226 | ||
10 | Signed-off-by: Thiruvadi Rajaraman <tajaraman@mvista.com> | ||
11 | |||
12 | Index: ruby-2.2.5/regparse.c | ||
13 | =================================================================== | ||
14 | --- ruby-2.2.5.orig/regparse.c 2017-09-12 16:33:21.977835068 +0530 | ||
15 | +++ ruby-2.2.5/regparse.c 2017-09-12 16:34:40.987117744 +0530 | ||
16 | @@ -3222,7 +3222,7 @@ | ||
17 | PUNFETCH; | ||
18 | prev = p; | ||
19 | num = scan_unsigned_octal_number(&p, end, 3, enc); | ||
20 | - if (num < 0) return ONIGERR_TOO_BIG_NUMBER; | ||
21 | + if (num < 0 || num >= 256) return ONIGERR_TOO_BIG_NUMBER; | ||
22 | if (p == prev) { /* can't read nothing. */ | ||
23 | num = 0; /* but, it's not error */ | ||
24 | } | ||
25 | @@ -3676,7 +3676,7 @@ | ||
26 | if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_OCTAL3)) { | ||
27 | prev = p; | ||
28 | num = scan_unsigned_octal_number(&p, end, (c == '0' ? 2:3), enc); | ||
29 | - if (num < 0) return ONIGERR_TOO_BIG_NUMBER; | ||
30 | + if (num < 0 || num >= 256) return ONIGERR_TOO_BIG_NUMBER; | ||
31 | if (p == prev) { /* can't read nothing. */ | ||
32 | num = 0; /* but, it's not error */ | ||
33 | } | ||
diff --git a/meta/recipes-devtools/ruby/ruby/CVE-2017-9227.patch b/meta/recipes-devtools/ruby/ruby/CVE-2017-9227.patch deleted file mode 100644 index f6eaefb7fd..0000000000 --- a/meta/recipes-devtools/ruby/ruby/CVE-2017-9227.patch +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | commit 9690d3ab1f9bcd2db8cbe1fe3ee4a5da606b8814 | ||
2 | Author: K.Kosako <kosako@sofnec.co.jp> | ||
3 | Date: Tue May 23 16:15:35 2017 +0900 | ||
4 | |||
5 | fix #58 : access to invalid address by reg->dmin value | ||
6 | |||
7 | Upstream-Status: backport | ||
8 | |||
9 | CVE: CVE-2017-9227 | ||
10 | Signed-off-by: Thiruvadi Rajaraman <trajaraman@mvista.com> | ||
11 | |||
12 | Index: ruby-2.2.5/regexec.c | ||
13 | =================================================================== | ||
14 | --- ruby-2.2.5.orig/regexec.c 2014-09-15 21:48:41.000000000 +0530 | ||
15 | +++ ruby-2.2.5/regexec.c 2017-08-30 12:18:04.054828426 +0530 | ||
16 | @@ -3678,6 +3678,8 @@ | ||
17 | } | ||
18 | else { | ||
19 | UChar *q = p + reg->dmin; | ||
20 | + | ||
21 | + if (q >= end) return 0; /* fail */ | ||
22 | while (p < q) p += enclen(reg->enc, p, end); | ||
23 | } | ||
24 | } | ||
diff --git a/meta/recipes-devtools/ruby/ruby/CVE-2017-9228.patch b/meta/recipes-devtools/ruby/ruby/CVE-2017-9228.patch deleted file mode 100644 index dc911bb20b..0000000000 --- a/meta/recipes-devtools/ruby/ruby/CVE-2017-9228.patch +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | commit 3b63d12038c8d8fc278e81c942fa9bec7c704c8b | ||
2 | Author: K.Kosako <kosako@sofnec.co.jp> | ||
3 | Date: Wed May 24 13:43:25 2017 +0900 | ||
4 | |||
5 | fix #60 : invalid state(CCS_VALUE) in parse_char_class() | ||
6 | |||
7 | Upstream-Status: Backport | ||
8 | |||
9 | CVE: CVE-2017-9228 | ||
10 | Signed-off-by: Thiruvadi Rajaraman <trajaraman@mvista.com> | ||
11 | |||
12 | Index: ruby-2.2.5/regparse.c | ||
13 | =================================================================== | ||
14 | --- ruby-2.2.5.orig/regparse.c 2014-09-16 08:14:10.000000000 +0530 | ||
15 | +++ ruby-2.2.5/regparse.c 2017-08-30 11:58:25.774275722 +0530 | ||
16 | @@ -4458,7 +4458,9 @@ | ||
17 | } | ||
18 | } | ||
19 | |||
20 | - *state = CCS_VALUE; | ||
21 | + if (*state != CCS_START) | ||
22 | + *state = CCS_VALUE; | ||
23 | + | ||
24 | *type = CCV_CLASS; | ||
25 | return 0; | ||
26 | } | ||
diff --git a/meta/recipes-devtools/ruby/ruby/CVE-2017-9229.patch b/meta/recipes-devtools/ruby/ruby/CVE-2017-9229.patch deleted file mode 100644 index 75bdfada57..0000000000 --- a/meta/recipes-devtools/ruby/ruby/CVE-2017-9229.patch +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | commit b690371bbf97794b4a1d3f295d4fb9a8b05d402d | ||
2 | Author: K.Kosako <kosako@sofnec.co.jp> | ||
3 | Date: Wed May 24 10:27:04 2017 +0900 | ||
4 | |||
5 | fix #59 : access to invalid address by reg->dmax value | ||
6 | |||
7 | Upstream-Status: Backport | ||
8 | |||
9 | CVE: CVE-2017-9229 | ||
10 | Signed-off-by: Thiruvadi Rajaraman <trajaraman@mvista.com> | ||
11 | |||
12 | Index: ruby-2.2.5/regexec.c | ||
13 | =================================================================== | ||
14 | --- ruby-2.2.5.orig/regexec.c 2017-09-13 12:17:08.429254209 +0530 | ||
15 | +++ ruby-2.2.5/regexec.c 2017-09-13 12:24:03.365312311 +0530 | ||
16 | @@ -3763,6 +3763,12 @@ | ||
17 | } | ||
18 | else { | ||
19 | if (reg->dmax != ONIG_INFINITE_DISTANCE) { | ||
20 | + if (p - str < reg->dmax) { | ||
21 | + *low = (UChar* )str; | ||
22 | + if (low_prev) | ||
23 | + *low_prev = onigenc_get_prev_char_head(reg->enc, str, *low, end); | ||
24 | + } | ||
25 | + else { | ||
26 | *low = p - reg->dmax; | ||
27 | if (*low > s) { | ||
28 | *low = onigenc_get_right_adjust_char_head_with_prev(reg->enc, s, | ||
29 | @@ -3776,6 +3782,7 @@ | ||
30 | *low_prev = onigenc_get_prev_char_head(reg->enc, | ||
31 | (pprev ? pprev : str), *low, end); | ||
32 | } | ||
33 | + } | ||
34 | } | ||
35 | } | ||
36 | /* no needs to adjust *high, *high is used as range check only */ | ||
diff --git a/meta/recipes-devtools/ruby/ruby/prevent-gc.patch b/meta/recipes-devtools/ruby/ruby/prevent-gc.patch deleted file mode 100644 index 2eaa955fba..0000000000 --- a/meta/recipes-devtools/ruby/ruby/prevent-gc.patch +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | Fix marshaling with gcc7. Based on upstream revision 57410: | ||
2 | https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57410 | ||
3 | https://github.com/ruby/ruby/commit/7c1b30a602ab109d8d5388d7dfb3c5b180ba24e1 | ||
4 | https://bugs.ruby-lang.org/issues/13150 | ||
5 | |||
6 | with the upstream patches intent ported to Ruby 2.2.5 | ||
7 | |||
8 | Upstream-Status: Backport | ||
9 | |||
10 | Signed-off-by: Joshua Lock <joshua.g.lock@intel.com> | ||
11 | |||
12 | Index: ruby-2.2.5/marshal.c | ||
13 | =================================================================== | ||
14 | --- ruby-2.2.5.orig/marshal.c | ||
15 | +++ ruby-2.2.5/marshal.c | ||
16 | @@ -17,7 +17,6 @@ | ||
17 | #include "ruby/io.h" | ||
18 | #include "ruby/st.h" | ||
19 | #include "ruby/util.h" | ||
20 | - | ||
21 | #include <math.h> | ||
22 | #ifdef HAVE_FLOAT_H | ||
23 | #include <float.h> | ||
24 | @@ -985,7 +984,7 @@ marshal_dump(int argc, VALUE *argv) | ||
25 | VALUE obj, port, a1, a2; | ||
26 | int limit = -1; | ||
27 | struct dump_arg *arg; | ||
28 | - VALUE wrapper; /* used to avoid memory leak in case of exception */ | ||
29 | + volatile VALUE wrapper; /* used to avoid memory leak in case of exception */ | ||
30 | |||
31 | port = Qnil; | ||
32 | rb_scan_args(argc, argv, "12", &obj, &a1, &a2); | ||
diff --git a/meta/recipes-devtools/ruby/ruby/ruby-CVE-2017-9224.patch b/meta/recipes-devtools/ruby/ruby/ruby-CVE-2017-9224.patch new file mode 100644 index 0000000000..848139b7e3 --- /dev/null +++ b/meta/recipes-devtools/ruby/ruby/ruby-CVE-2017-9224.patch | |||
@@ -0,0 +1,41 @@ | |||
1 | From 690313a061f7a4fa614ec5cc8368b4f2284e059b Mon Sep 17 00:00:00 2001 | ||
2 | From: "K.Kosako" <kosako@sofnec.co.jp> | ||
3 | Date: Tue, 23 May 2017 10:28:58 +0900 | ||
4 | Subject: [PATCH] fix #57 : DATA_ENSURE() check must be before data access | ||
5 | |||
6 | --- | ||
7 | regexec.c | 5 ----- | ||
8 | 1 file changed, 5 deletions(-) | ||
9 | |||
10 | --- end of original header | ||
11 | |||
12 | CVE: CVE-2017-9224 | ||
13 | |||
14 | Context modified so that patch applies for version 2.4.1. | ||
15 | |||
16 | Upstream-Status: Pending | ||
17 | Signed-off-by: Joe Slater <joe.slater@windriver.com> | ||
18 | |||
19 | |||
20 | diff --git a/regexec.c b/regexec.c | ||
21 | index 35fef11..d4e577d 100644 | ||
22 | --- a/regexec.c | ||
23 | +++ b/regexec.c | ||
24 | @@ -1473,14 +1473,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, | ||
25 | NEXT; | ||
26 | |||
27 | CASE(OP_EXACT1) MOP_IN(OP_EXACT1); | ||
28 | -#if 0 | ||
29 | DATA_ENSURE(1); | ||
30 | if (*p != *s) goto fail; | ||
31 | p++; s++; | ||
32 | -#endif | ||
33 | - if (*p != *s++) goto fail; | ||
34 | - DATA_ENSURE(0); | ||
35 | - p++; | ||
36 | MOP_OUT; | ||
37 | break; | ||
38 | |||
39 | -- | ||
40 | 1.7.9.5 | ||
41 | |||
diff --git a/meta/recipes-devtools/ruby/ruby/ruby-CVE-2017-9226.patch b/meta/recipes-devtools/ruby/ruby/ruby-CVE-2017-9226.patch new file mode 100644 index 0000000000..0f2a4307cc --- /dev/null +++ b/meta/recipes-devtools/ruby/ruby/ruby-CVE-2017-9226.patch | |||
@@ -0,0 +1,41 @@ | |||
1 | From b4bf968ad52afe14e60a2dc8a95d3555c543353a Mon Sep 17 00:00:00 2001 | ||
2 | From: "K.Kosako" <kosako@sofnec.co.jp> | ||
3 | Date: Thu, 18 May 2017 17:05:27 +0900 | ||
4 | Subject: [PATCH] fix #55 : check too big code point value for single byte | ||
5 | value in next_state_val() | ||
6 | |||
7 | --- | ||
8 | regparse.c | 3 +++ | ||
9 | 1 file changed, 3 insertions(+) | ||
10 | |||
11 | --- end of original header | ||
12 | |||
13 | CVE: CVE-2017-9226 | ||
14 | |||
15 | Add check for octal number bigger than 255. | ||
16 | |||
17 | Upstream-Status: Pending | ||
18 | Signed-off-by: Joe Slater <joe.slater@windriver.com> | ||
19 | |||
20 | |||
21 | --- ruby-2.4.1.orig/regparse.c | ||
22 | +++ ruby-2.4.1/regparse.c | ||
23 | @@ -3644,7 +3644,7 @@ fetch_token(OnigToken* tok, UChar** src, | ||
24 | if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_OCTAL3)) { | ||
25 | prev = p; | ||
26 | num = scan_unsigned_octal_number(&p, end, (c == '0' ? 2:3), enc); | ||
27 | - if (num < 0) return ONIGERR_TOO_BIG_NUMBER; | ||
28 | + if (num < 0 || 0xff < num) return ONIGERR_TOO_BIG_NUMBER; | ||
29 | if (p == prev) { /* can't read nothing. */ | ||
30 | num = 0; /* but, it's not error */ | ||
31 | } | ||
32 | @@ -4450,6 +4450,9 @@ next_state_val(CClassNode* cc, CClassNod | ||
33 | switch (*state) { | ||
34 | case CCS_VALUE: | ||
35 | if (*type == CCV_SB) { | ||
36 | + if (*vs > 0xff) | ||
37 | + return ONIGERR_INVALID_CODE_POINT_VALUE; | ||
38 | + | ||
39 | BITSET_SET_BIT_CHKDUP(cc->bs, (int )(*vs)); | ||
40 | if (IS_NOT_NULL(asc_cc)) | ||
41 | BITSET_SET_BIT(asc_cc->bs, (int )(*vs)); | ||
diff --git a/meta/recipes-devtools/ruby/ruby/ruby-CVE-2017-9227.patch b/meta/recipes-devtools/ruby/ruby/ruby-CVE-2017-9227.patch new file mode 100644 index 0000000000..85e7ccb369 --- /dev/null +++ b/meta/recipes-devtools/ruby/ruby/ruby-CVE-2017-9227.patch | |||
@@ -0,0 +1,32 @@ | |||
1 | From 9690d3ab1f9bcd2db8cbe1fe3ee4a5da606b8814 Mon Sep 17 00:00:00 2001 | ||
2 | From: "K.Kosako" <kosako@sofnec.co.jp> | ||
3 | Date: Tue, 23 May 2017 16:15:35 +0900 | ||
4 | Subject: [PATCH] fix #58 : access to invalid address by reg->dmin value | ||
5 | |||
6 | --- | ||
7 | regexec.c | 2 ++ | ||
8 | 1 file changed, 2 insertions(+) | ||
9 | |||
10 | --- end of original header | ||
11 | |||
12 | CVE: CVE-2017-9227 | ||
13 | |||
14 | Upstream-Status: Inappropriate [not author] | ||
15 | Signed-off-by: Joe Slater <joe.slater@windriver.com> | ||
16 | |||
17 | diff --git a/regexec.c b/regexec.c | ||
18 | index d4e577d..2fa0f3d 100644 | ||
19 | --- a/regexec.c | ||
20 | +++ b/regexec.c | ||
21 | @@ -3154,6 +3154,8 @@ forward_search_range(regex_t* reg, const UChar* str, const UChar* end, UChar* s, | ||
22 | } | ||
23 | else { | ||
24 | UChar *q = p + reg->dmin; | ||
25 | + | ||
26 | + if (q >= end) return 0; /* fail */ | ||
27 | while (p < q) p += enclen(reg->enc, p, end); | ||
28 | } | ||
29 | } | ||
30 | -- | ||
31 | 1.7.9.5 | ||
32 | |||
diff --git a/meta/recipes-devtools/ruby/ruby/ruby-CVE-2017-9228.patch b/meta/recipes-devtools/ruby/ruby/ruby-CVE-2017-9228.patch new file mode 100644 index 0000000000..d8bfba486c --- /dev/null +++ b/meta/recipes-devtools/ruby/ruby/ruby-CVE-2017-9228.patch | |||
@@ -0,0 +1,34 @@ | |||
1 | From 3b63d12038c8d8fc278e81c942fa9bec7c704c8b Mon Sep 17 00:00:00 2001 | ||
2 | From: "K.Kosako" <kosako@sofnec.co.jp> | ||
3 | Date: Wed, 24 May 2017 13:43:25 +0900 | ||
4 | Subject: [PATCH] fix #60 : invalid state(CCS_VALUE) in parse_char_class() | ||
5 | |||
6 | --- | ||
7 | regparse.c | 4 +++- | ||
8 | 1 file changed, 3 insertions(+), 1 deletion(-) | ||
9 | |||
10 | --- end of original header | ||
11 | |||
12 | CVE: CVE-2017-9228 | ||
13 | |||
14 | Upstream-Status: Inappropriate [not author] | ||
15 | Signed-off-by: Joe Slater <joe.slater@windriver.com> | ||
16 | |||
17 | diff --git a/regparse.c b/regparse.c | ||
18 | index 69875fa..1988747 100644 | ||
19 | --- a/regparse.c | ||
20 | +++ b/regparse.c | ||
21 | @@ -4081,7 +4081,9 @@ next_state_class(CClassNode* cc, OnigCodePoint* vs, enum CCVALTYPE* type, | ||
22 | } | ||
23 | } | ||
24 | |||
25 | - *state = CCS_VALUE; | ||
26 | + if (*state != CCS_START) | ||
27 | + *state = CCS_VALUE; | ||
28 | + | ||
29 | *type = CCV_CLASS; | ||
30 | return 0; | ||
31 | } | ||
32 | -- | ||
33 | 1.7.9.5 | ||
34 | |||
diff --git a/meta/recipes-devtools/ruby/ruby/ruby-CVE-2017-9229.patch b/meta/recipes-devtools/ruby/ruby/ruby-CVE-2017-9229.patch new file mode 100644 index 0000000000..6e765bf6dc --- /dev/null +++ b/meta/recipes-devtools/ruby/ruby/ruby-CVE-2017-9229.patch | |||
@@ -0,0 +1,59 @@ | |||
1 | From b690371bbf97794b4a1d3f295d4fb9a8b05d402d Mon Sep 17 00:00:00 2001 | ||
2 | From: "K.Kosako" <kosako@sofnec.co.jp> | ||
3 | Date: Wed, 24 May 2017 10:27:04 +0900 | ||
4 | Subject: [PATCH] fix #59 : access to invalid address by reg->dmax value | ||
5 | |||
6 | --- | ||
7 | regexec.c | 27 +++++++++++++++++---------- | ||
8 | 1 file changed, 17 insertions(+), 10 deletions(-) | ||
9 | |||
10 | --- end of original header | ||
11 | |||
12 | CVE: CVE-2017-9229 | ||
13 | |||
14 | Upstream-Status: Inappropriate [not author] | ||
15 | Signed-off-by: Joe Slater <joe.slater@windriver.com> | ||
16 | |||
17 | diff --git a/regexec.c b/regexec.c | ||
18 | index 49bcc50..c0626ef 100644 | ||
19 | --- a/regexec.c | ||
20 | +++ b/regexec.c | ||
21 | @@ -3756,18 +3756,25 @@ forward_search_range(regex_t* reg, const | ||
22 | } | ||
23 | else { | ||
24 | if (reg->dmax != ONIG_INFINITE_DISTANCE) { | ||
25 | - *low = p - reg->dmax; | ||
26 | - if (*low > s) { | ||
27 | - *low = onigenc_get_right_adjust_char_head_with_prev(reg->enc, s, | ||
28 | - *low, end, (const UChar** )low_prev); | ||
29 | - if (low_prev && IS_NULL(*low_prev)) | ||
30 | - *low_prev = onigenc_get_prev_char_head(reg->enc, | ||
31 | - (pprev ? pprev : s), *low, end); | ||
32 | + if (p - str < reg->dmax) { | ||
33 | + *low = (UChar* )str; | ||
34 | + if (low_prev) | ||
35 | + *low_prev = onigenc_get_prev_char_head(reg->enc, str, *low, end); | ||
36 | } | ||
37 | else { | ||
38 | - if (low_prev) | ||
39 | - *low_prev = onigenc_get_prev_char_head(reg->enc, | ||
40 | - (pprev ? pprev : str), *low, end); | ||
41 | + *low = p - reg->dmax; | ||
42 | + if (*low > s) { | ||
43 | + *low = onigenc_get_right_adjust_char_head_with_prev(reg->enc, s, | ||
44 | + *low, end, (const UChar** )low_prev); | ||
45 | + if (low_prev && IS_NULL(*low_prev)) | ||
46 | + *low_prev = onigenc_get_prev_char_head(reg->enc, | ||
47 | + (pprev ? pprev : s), *low, end); | ||
48 | + } | ||
49 | + else { | ||
50 | + if (low_prev) | ||
51 | + *low_prev = onigenc_get_prev_char_head(reg->enc, | ||
52 | + (pprev ? pprev : str), *low, end); | ||
53 | + } | ||
54 | } | ||
55 | } | ||
56 | } | ||
57 | -- | ||
58 | 1.7.9.5 | ||
59 | |||
diff --git a/meta/recipes-devtools/ruby/ruby_2.2.5.bb b/meta/recipes-devtools/ruby/ruby_2.4.0.bb index 750ddc690f..b08837cfe8 100644 --- a/meta/recipes-devtools/ruby/ruby_2.2.5.bb +++ b/meta/recipes-devtools/ruby/ruby_2.4.0.bb | |||
@@ -1,17 +1,16 @@ | |||
1 | require ruby.inc | 1 | require ruby.inc |
2 | 2 | ||
3 | SRC_URI[md5sum] = "bd8e349d4fb2c75d90817649674f94be" | 3 | SRC_URI += " \ |
4 | SRC_URI[sha256sum] = "30c4b31697a4ca4ea0c8db8ad30cf45e6690a0f09687e5d483c933c03ca335e3" | 4 | file://ruby-CVE-2017-9224.patch \ |
5 | 5 | file://ruby-CVE-2017-9226.patch \ | |
6 | SRC_URI += "file://prevent-gc.patch \ | 6 | file://ruby-CVE-2017-9227.patch \ |
7 | file://CVE-2016-7798.patch \ | 7 | file://ruby-CVE-2017-9228.patch \ |
8 | file://CVE-2017-9227.patch \ | 8 | file://ruby-CVE-2017-9229.patch \ |
9 | file://CVE-2017-9228.patch \ | 9 | file://CVE-2017-14064.patch \ |
10 | file://CVE-2017-9226.patch \ | 10 | " |
11 | file://CVE-2017-9229.patch \ | 11 | |
12 | file://CVE-2017-14033.patch \ | 12 | SRC_URI[md5sum] = "7e9485dcdb86ff52662728de2003e625" |
13 | file://CVE-2017-14064.patch \ | 13 | SRC_URI[sha256sum] = "152fd0bd15a90b4a18213448f485d4b53e9f7662e1508190aa5b702446b29e3d" |
14 | " | ||
15 | 14 | ||
16 | # it's unknown to configure script, but then passed to extconf.rb | 15 | # it's unknown to configure script, but then passed to extconf.rb |
17 | # maybe it's not really needed as we're hardcoding the result with | 16 | # maybe it's not really needed as we're hardcoding the result with |
@@ -25,6 +24,8 @@ PACKAGECONFIG[valgrind] = "--with-valgrind=yes, --with-valgrind=no, valgrind" | |||
25 | PACKAGECONFIG[gpm] = "--with-gmp=yes, --with-gmp=no, gmp" | 24 | PACKAGECONFIG[gpm] = "--with-gmp=yes, --with-gmp=no, gmp" |
26 | PACKAGECONFIG[ipv6] = ",--enable-wide-getaddrinfo," | 25 | PACKAGECONFIG[ipv6] = ",--enable-wide-getaddrinfo," |
27 | 26 | ||
27 | EXTRA_AUTORECONF += "--exclude=aclocal" | ||
28 | |||
28 | EXTRA_OECONF = "\ | 29 | EXTRA_OECONF = "\ |
29 | --disable-versioned-paths \ | 30 | --disable-versioned-paths \ |
30 | --disable-rpath \ | 31 | --disable-rpath \ |