Browse code

ruby-CVE-2017-14064.patch (Bug 1959303)

Change-Id: I3b71c6cd45f1c3c99548b8bc7ac370fc28464bb5
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/3785
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Alexey Makhalov <amakhalov@vmware.com>

xiaolin-vmware authored on 2017/09/16 05:49:09
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,70 @@
0
+diff --git a/ext/json/generator/generator.c b/ext/json/generator/generator.c
1
+index a135e28348..2cdca5685f 100644
2
+--- a/ext/json/generator/generator.c
3
+@@ -301,7 +301,7 @@ static char *fstrndup(const char *ptr, unsigned long len) {
4
+   char *result;
5
+   if (len <= 0) return NULL;
6
+   result = ALLOC_N(char, len);
7
+-  memccpy(result, ptr, 0, len);
8
++  memcpy(result, ptr, len);
9
+   return result;
10
+ }
11
+ 
12
+@@ -1055,7 +1055,7 @@ static VALUE cState_indent_set(VALUE self, VALUE indent)
13
+         }
14
+     } else {
15
+         if (state->indent) ruby_xfree(state->indent);
16
+-        state->indent = strdup(RSTRING_PTR(indent));
17
++        state->indent = fstrndup(RSTRING_PTR(indent), len);
18
+         state->indent_len = len;
19
+     }
20
+     return Qnil;
21
+@@ -1093,7 +1093,7 @@ static VALUE cState_space_set(VALUE self, VALUE space)
22
+         }
23
+     } else {
24
+         if (state->space) ruby_xfree(state->space);
25
+-        state->space = strdup(RSTRING_PTR(space));
26
++        state->space = fstrndup(RSTRING_PTR(space), len);
27
+         state->space_len = len;
28
+     }
29
+     return Qnil;
30
+@@ -1129,7 +1129,7 @@ static VALUE cState_space_before_set(VALUE self, VALUE space_before)
31
+         }
32
+     } else {
33
+         if (state->space_before) ruby_xfree(state->space_before);
34
+-        state->space_before = strdup(RSTRING_PTR(space_before));
35
++        state->space_before = fstrndup(RSTRING_PTR(space_before), len);
36
+         state->space_before_len = len;
37
+     }
38
+     return Qnil;
39
+@@ -1166,7 +1166,7 @@ static VALUE cState_object_nl_set(VALUE self, VALUE object_nl)
40
+         }
41
+     } else {
42
+         if (state->object_nl) ruby_xfree(state->object_nl);
43
+-        state->object_nl = strdup(RSTRING_PTR(object_nl));
44
++        state->object_nl = fstrndup(RSTRING_PTR(object_nl), len);
45
+         state->object_nl_len = len;
46
+     }
47
+     return Qnil;
48
+@@ -1201,7 +1201,7 @@ static VALUE cState_array_nl_set(VALUE self, VALUE array_nl)
49
+         }
50
+     } else {
51
+         if (state->array_nl) ruby_xfree(state->array_nl);
52
+-        state->array_nl = strdup(RSTRING_PTR(array_nl));
53
++        state->array_nl = fstrndup(RSTRING_PTR(array_nl), len);
54
+         state->array_nl_len = len;
55
+     }
56
+     return Qnil;
57
+diff --git ext/json/generator/generator.h ext/json/generator/generator.h
58
+index 298c0a4965..6bbf817b7d 100644
59
+--- a/ext/json/generator/generator.h
60
+@@ -1,7 +1,6 @@
61
+ #ifndef _GENERATOR_H_
62
+ #define _GENERATOR_H_
63
+ 
64
+-#include <string.h>
65
+ #include <math.h>
66
+ #include <ctype.h>
67
+ 
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:    Ruby
2 2
 Name:       ruby
3 3
 Version:    2.4.1
4
-Release:    4%{?dist}
4
+Release:    5%{?dist}
5 5
 License:    BSDL
6 6
 URL:        https://www.ruby-lang.org/en/
7 7
 Group:      System Environment/Security
... ...
@@ -14,6 +14,8 @@ Patch1:     ruby-CVE-2017-9226.patch
14 14
 Patch2:     ruby-CVE-2017-9227.patch
15 15
 Patch3:     ruby-CVE-2017-9229.patch
16 16
 Patch4:     ruby-CVE-2017-9228.patch
17
+#https://github.com/flori/json/commit/8f782fd8e181d9cfe9387ded43a5ca9692266b85
18
+Patch5:     ruby-CVE-2017-14064.patch
17 19
 BuildRequires:  openssl-devel
18 20
 BuildRequires:  ca-certificates
19 21
 BuildRequires:  readline-devel
... ...
@@ -33,6 +35,7 @@ This is useful for object-oriented scripting.
33 33
 %patch2 -p1
34 34
 %patch3 -p1
35 35
 %patch4 -p1
36
+%patch5 -p1
36 37
 %build
37 38
 ./configure \
38 39
     --prefix=%{_prefix}   \
... ...
@@ -63,6 +66,8 @@ rm -rf %{buildroot}/*
63 63
 %{_docdir}/%{name}-%{version}
64 64
 %{_mandir}/man1/*
65 65
 %changelog
66
+*   Fri Sep 15 2017 Xiaolin Li <xiaolinl@vmware.com> 2.4.1-5
67
+-   [security] CVE-2017-14064
66 68
 *   Tue Sep 05 2017 Chang Lee <changlee@vmware.com> 2.4.1-4
67 69
 -   Built with copy preserve mode and fixed %check
68 70
 *   Mon Jul 24 2017 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 2.4.1-3