Browse code

subversion : Fix CVE-2016-8734

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

xiaolin-vmware authored on 2017/12/10 01:32:50
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,195 @@
0
+Patches:
1
+========
2
+
3
+  Patch for Subversion 1.9.4:
4
+[[[
5
+Index: subversion/libsvn_ra_serf/xml.c
6
+
7
+===================================================================
8
+
9
+--- subversion/libsvn_ra_serf/xml.c	(revision 1768981)
10
+@@ -988,6 +988,30 @@ expat_cdata(void *userData, const char *data, int len)
11
+ #endif
12
+ }
13
+ 
14
++#if XML_VERSION_AT_LEAST(1, 95, 8)
15
++static void
16
++expat_entity_declaration(void *userData,
17
++                         const XML_Char *entityName,
18
++                         int is_parameter_entity,
19
++                         const XML_Char *value,
20
++                         int value_length,
21
++                         const XML_Char *base,
22
++                         const XML_Char *systemId,
23
++                         const XML_Char *publicId,
24
++                         const XML_Char *notationName)
25
++{
26
++  struct expat_ctx_t *ectx = userData;
27
++ 
28
++  /* Stop the parser if an entity declaration is hit. */
29
++  XML_StopParser(ectx->parser, 0 /* resumable */);
30
++}
31
++#else
32
++/* A noop default_handler. */
33
++static void
34
++expat_default_handler(void *userData, const XML_Char *s, int len)
35
++{
36
++}
37
++#endif
38
+
39
+ /* Implements svn_ra_serf__response_handler_t */
40
+ static svn_error_t *
41
+ expat_response_handler(serf_request_t *request,
42
+@@ -1042,6 +1066,12 @@
43
+
44
+       XML_SetUserData(ectx->parser, ectx);
45
+       XML_SetElementHandler(ectx->parser, expat_start, expat_end);
46
+       XML_SetCharacterDataHandler(ectx->parser, expat_cdata);
47
++
48
++#if XML_VERSION_AT_LEAST(1, 95, 8)
49
++      XML_SetEntityDeclHandler(ectx->parser, expat_entity_declaration);
50
++#else
51
++      XML_SetDefaultHandler(ectx->parser, expat_default_handler);
52
++#endif
53
+     }
54
+ 
55
+   while (1)
56
+Index: subversion/libsvn_subr/xml.c
57
+
58
+===================================================================
59
+
60
+--- subversion/libsvn_subr/xml.c	(revision 1768981)
61
+@@ -46,6 +46,14 @@
62
+ #error Expat is unusable -- it has been compiled for wide characters
63
+ #endif
64
+ 
65
++#ifndef XML_VERSION_AT_LEAST
66
++#define XML_VERSION_AT_LEAST(major,minor,patch)                  \
67
++(((major) < XML_MAJOR_VERSION)                                       \
68
++ || ((major) == XML_MAJOR_VERSION && (minor) < XML_MINOR_VERSION)    \
69
++ || ((major) == XML_MAJOR_VERSION && (minor) == XML_MINOR_VERSION && \
70
++     (patch) <= XML_MICRO_VERSION))
71
++#endif /* XML_VERSION_AT_LEAST */
72
++
73
+ const char *
74
+ svn_xml__compiled_version(void)
75
+ {
76
+@@ -361,6 +369,28 @@ static void expat_data_handler(void *userData, const XML_Char *s, int len)
77
+   (*svn_parser->data_handler)(svn_parser->baton, s, (apr_size_t)len);
78
+ }
79
+ 
80
++#if XML_VERSION_AT_LEAST(1, 95, 8)
81
++static void expat_entity_declaration(void *userData,
82
++                                     const XML_Char *entityName,
83
++                                     int is_parameter_entity,
84
++                                     const XML_Char *value,
85
++                                     int value_length,
86
++                                     const XML_Char *base,
87
++                                     const XML_Char *systemId,
88
++                                     const XML_Char *publicId,
89
++                                     const XML_Char *notationName)
90
++{
91
++  svn_xml_parser_t *svn_parser = userData;
92
++
93
++  /* Stop the parser if an entity declaration is hit. */
94
++  XML_StopParser(svn_parser->parser, 0 /* resumable */);
95
++}
96
++#else
97
++/* A noop default_handler. */
98
++static void expat_default_handler(void *userData, const XML_Char *s, int len)
99
++{
100
++}
101
++#endif
102
+ 
103
+ /*** Making a parser. ***/
104
+ 
105
+@@ -382,6 +412,12 @@ svn_xml_make_parser(void *baton,
106
+   XML_SetCharacterDataHandler(parser,
107
+                               data_handler ? expat_data_handler : NULL);
108
+ 
109
++#if XML_VERSION_AT_LEAST(1, 95, 8)
110
++  XML_SetEntityDeclHandler(parser, expat_entity_declaration);
111
++#else
112
++  XML_SetDefaultHandler(parser, expat_default_handler);
113
++#endif
114
++
115
+   /* ### we probably don't want this pool; or at least we should pass it
116
+      ### to the callbacks and clear it periodically.  */
117
+   subpool = svn_pool_create(pool);
118
+@@ -499,7 +499,9 @@ void svn_xml_signal_bailout(svn_error_t *error,
119
+   /* This will cause the current XML_Parse() call to finish quickly! */
120
+   XML_SetElementHandler(svn_parser->parser, NULL, NULL);
121
+   XML_SetCharacterDataHandler(svn_parser->parser, NULL);
122
+-
123
++#if XML_VERSION_AT_LEAST(1, 95, 8)
124
++  XML_SetEntityDeclHandler(svn_parser->parser, NULL);
125
++#endif
126
+   /* Once outside of XML_Parse(), the existence of this field will
127
+      cause svn_delta_parse()'s main read-loop to return error. */
128
+   svn_parser->error = error;
129
+Index: tools/server-side/mod_dontdothat/mod_dontdothat.c
130
+===================================================================
131
+--- tools/server-side/mod_dontdothat/mod_dontdothat.c	(revision 1768981)
132
+@@ -42,6 +42,14 @@
133
+ 
134
+ extern module AP_MODULE_DECLARE_DATA dontdothat_module;
135
+ 
136
++#ifndef XML_VERSION_AT_LEAST
137
++#define XML_VERSION_AT_LEAST(major,minor,patch)                  \
138
++(((major) < XML_MAJOR_VERSION)                                       \
139
++ || ((major) == XML_MAJOR_VERSION && (minor) < XML_MINOR_VERSION)    \
140
++ || ((major) == XML_MAJOR_VERSION && (minor) == XML_MINOR_VERSION && \
141
++     (patch) <= XML_MICRO_VERSION))
142
++#endif /* XML_VERSION_AT_LEAST */
143
++
144
+ typedef struct dontdothat_config_rec {
145
+   const char *config_file;
146
+   const char *base_path;
147
+@@ -559,6 +559,31 @@ end_element(void *baton, const char *name)
148
+     }
149
+ }
150
+ 
151
++#if XML_VERSION_AT_LEAST(1, 95, 8)
152
++static void
153
++expat_entity_declaration(void *userData,
154
++                         const XML_Char *entityName,
155
++                         int is_parameter_entity,
156
++                         const XML_Char *value,
157
++                         int value_length,
158
++                         const XML_Char *base,
159
++                         const XML_Char *systemId,
160
++                         const XML_Char *publicId,
161
++                         const XML_Char *notationName)
162
++{
163
++  dontdothat_filter_ctx *ctx = userData;
164
++
165
++  /* Stop the parser if an entity declaration is hit. */
166
++  XML_StopParser(ctx->xmlp, 0 /* resumable */);
167
++}
168
++#else
169
++/* A noop default_handler. */
170
++static void
171
++expat_default_handler(void *userData, const XML_Char *s, int len)
172
++{
173
++}
174
++#endif
175
++
176
+ static svn_boolean_t
177
+ is_valid_wildcard(const char *wc)
178
+ {
179
+@@ -729,6 +729,12 @@ dontdothat_insert_filters(request_rec *r)
180
+       XML_SetElementHandler(ctx->xmlp, start_element, end_element);
181
+       XML_SetCharacterDataHandler(ctx->xmlp, cdata);
182
+ 
183
++#if XML_VERSION_AT_LEAST(1, 95, 8)
184
++      XML_SetEntityDeclHandler(ctx->xmlp, expat_entity_declaration);
185
++#else
186
++      XML_SetDefaultHandler(ctx->xmlp, expat_default_handler);
187
++#endif
188
++
189
+       ap_add_input_filter("DONTDOTHAT_FILTER", ctx, r, r->connection);
190
+     }
191
+ }
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:        The Apache Subversion control system
2 2
 Name:           subversion
3 3
 Version:        1.9.4
4
-Release:        3%{?dist}
4
+Release:        4%{?dist}
5 5
 License:        Apache License 2.0
6 6
 URL:            http://subversion.apache.org/
7 7
 Group:          Utilities/System
... ...
@@ -10,6 +10,7 @@ Distribution:   Photon
10 10
 Source0:        http://archive.apache.org/dist/%{name}/%{name}-%{version}.tar.bz2
11 11
 %define sha1    subversion=bc7d51fdda43bea01e1272dfe9d23d0a9d6cd11c
12 12
 Patch0:         subversion-CVE-2017-9800.patch
13
+Patch1:         subversion-CVE-2016-8734.patch
13 14
 Requires:       apr
14 15
 Requires:       apr-util
15 16
 BuildRequires:  apr-devel
... ...
@@ -31,6 +32,7 @@ Requires:   %{name} = %{version}
31 31
 %prep
32 32
 %setup -q
33 33
 %patch0 -p1
34
+%patch1 -p0
34 35
 %build
35 36
 ./configure --prefix=%{_prefix}         \
36 37
             --disable-static            \
... ...
@@ -54,6 +56,8 @@ make -j1 DESTDIR=%{buildroot} install
54 54
 %exclude %{_libdir}/debug/
55 55
 
56 56
 %changelog
57
+*   Thu Dec 07 2017 Xiaolin Li <xiaolinl@vmware.com> 1.9.4-4
58
+-   Fix CVE-2016-8734
57 59
 *   Tue Sep 26 2017 Anish Swaminathan <anishs@vmware.com> 1.9.4-3
58 60
 -   Release bump for expat version update
59 61
 *   Mon Aug 28 2017 Xiaolin Li <xiaolinl@vmware.com> 1.9.4-2