forked from AndDiSa/platform_manifest-Grouper-AOSP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
external_chromium_libpac.patch
203 lines (192 loc) · 5.74 KB
/
external_chromium_libpac.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
diff --git a/Android.mk b/Android.mk
index e8a2b26..ae0e768 100644
--- a/Android.mk
+++ b/Android.mk
@@ -18,6 +18,7 @@ LOCAL_CFLAGS += \
-Wno-import \
-Wno-format \
-Wno-unused-parameter \
+ -Werror
LOCAL_C_INCLUDES += $(LOCAL_PATH)/src $(LOCAL_PATH)/../v8
@@ -28,3 +29,5 @@ LOCAL_SHARED_LIBRARIES := libutils liblog libicuuc libicui18n
LOCAL_CXX_STL := libc++
include $(BUILD_SHARED_LIBRARY)
+
+include $(LOCAL_PATH)/test/Android.mk
diff --git a/src/net_util.cc b/src/net_util.cc
index 992cdd1..8eef03a 100644
--- a/src/net_util.cc
+++ b/src/net_util.cc
@@ -64,7 +64,7 @@ bool ParseCIDRBlock(const std::string& cidr_literal,
// <IPv6-literal> "/" <number of bits>
std::vector<std::string> parts;
- unsigned int split = cidr_literal.find('/');
+ size_t split = cidr_literal.find('/');
if (split == std::string::npos)
return false;
parts.push_back(cidr_literal.substr(0, split));
diff --git a/src/proxy_resolver_v8.cc b/src/proxy_resolver_v8.cc
index f978694..0504b03 100644
--- a/src/proxy_resolver_v8.cc
+++ b/src/proxy_resolver_v8.cc
@@ -762,6 +762,10 @@ int ProxyResolverV8::SetPacScript(const android::String16& script_data) {
if (script_data.size() == 0)
return ERR_PAC_SCRIPT_FAILED;
+ // Disable JIT
+ static const char kNoOpt[] = "--no-opt";
+ v8::V8::SetFlagsFromString(kNoOpt, strlen(kNoOpt));
+
// Try parsing the PAC script.
ArrayBufferAllocator allocator;
v8::Isolate::CreateParams create_params;
diff --git a/test/Android.mk b/test/Android.mk
index 9c9722e..edf9107 100644
--- a/test/Android.mk
+++ b/test/Android.mk
@@ -18,6 +18,6 @@ LOCAL_CFLAGS += \
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../src $(LOCAL_PATH)/ external/v8
-LOCAL_SHARED_LIBRARIES := libpac libutils liblog
+LOCAL_SHARED_LIBRARIES := libpac libutils liblog libandroid_runtime
include $(BUILD_NATIVE_TEST)
diff --git a/test/js-unittest/b_132073833.js b/test/js-unittest/b_132073833.js
new file mode 100644
index 0000000..79d1967
--- /dev/null
+++ b/test/js-unittest/b_132073833.js
@@ -0,0 +1,21 @@
+function FindProxyForURL(url, host){
+ function opt() {
+ opt['x'] = 1.1;
+ try {
+ Object.create(object);
+ } catch (e) {
+ }
+
+ for (let i = 0; i < 100000; i++) {
+
+ }
+ }
+
+ opt();
+ object = opt;
+ opt();
+
+ return "DIRECT";
+}
+
+var object;
\ No newline at end of file
diff --git a/test/js-unittest/change_element_kind.js b/test/js-unittest/change_element_kind.js
new file mode 100644
index 0000000..335d59e
--- /dev/null
+++ b/test/js-unittest/change_element_kind.js
@@ -0,0 +1,15 @@
+// PAC script with getter that changes element kind.
+
+function FindProxyForURL(url, host) {
+ let arr = [];
+ arr[1000] = 0x1234;
+
+ arr.__defineGetter__(256, function () {
+ delete arr[256];
+ arr.unshift(1.1);
+ });
+
+ let results = Object.entries(arr);
+ let str = results.toString();
+ return "DIRECT";
+}
diff --git a/test/proxy_resolver_v8_unittest.cc b/test/proxy_resolver_v8_unittest.cc
index ad9c826..73e4405 100644
--- a/test/proxy_resolver_v8_unittest.cc
+++ b/test/proxy_resolver_v8_unittest.cc
@@ -544,5 +544,33 @@ TEST(ProxyResolverV8Test, DNSResolutionOfInternationDomainName) {
EXPECT_EQ("xn--bcher-kva.ch", bindings->dns_resolves_ex[0]);
}
+TEST(ProxyResolverV8Test, GetterChangesElementKind) {
+ ProxyResolverV8WithMockBindings resolver(new MockJSBindings());
+ int result = resolver.SetPacScript(String16(CHANGE_ELEMENT_KIND_JS));
+ EXPECT_EQ(OK, result);
+
+ // Execute FindProxyForURL().
+ result = resolver.GetProxyForURL(kQueryUrl, kQueryHost, &kResults);
+
+ EXPECT_EQ(OK, result);
+ std::vector<std::string> proxies = string16ToProxyList(kResults);
+ EXPECT_EQ(1U, proxies.size());
+ EXPECT_EQ("DIRECT", proxies[0]);
+}
+
+TEST(ProxyResolverV8Test, B_132073833) {
+ ProxyResolverV8WithMockBindings resolver(new MockJSBindings());
+ int result = resolver.SetPacScript(String16(B_132073833_JS));
+ EXPECT_EQ(OK, result);
+
+ // Execute FindProxyForURL().
+ result = resolver.GetProxyForURL(kQueryUrl, kQueryHost, &kResults);
+
+ EXPECT_EQ(OK, result);
+ std::vector<std::string> proxies = string16ToProxyList(kResults);
+ EXPECT_EQ(1U, proxies.size());
+ EXPECT_EQ("DIRECT", proxies[0]);
+}
+
} // namespace
} // namespace net
diff --git a/test/proxy_test_script.h b/test/proxy_test_script.h
index 1042366..aa10016 100644
--- a/test/proxy_test_script.h
+++ b/test/proxy_test_script.h
@@ -4,6 +4,29 @@
#ifndef PROXY_TEST_SCRIPT_H_
#define PROXY_TEST_SCRIPT_H_
+#define B_132073833_JS \
+ "function FindProxyForURL(url, host){\n" \
+ " function opt() {\n" \
+ " opt['x'] = 1.1;\n" \
+ " try {\n" \
+ " Object.create(object);\n" \
+ " } catch (e) {\n" \
+ " }\n" \
+ "\n" \
+ " for (let i = 0; i < 100000; i++) {\n" \
+ "\n" \
+ " }\n" \
+ " }\n" \
+ "\n" \
+ " opt();\n" \
+ " object = opt;\n" \
+ " opt();\n" \
+ "\n" \
+ " return \"DIRECT\";\n" \
+ "}\n" \
+ "\n" \
+ "var object;\n" \
+
#define BINDING_FROM_GLOBAL_JS \
"// Calls a bindings outside of FindProxyForURL(). This causes the code to\n" \
"// get exercised during initialization.\n" \
@@ -78,6 +101,23 @@
"function fn() {}\n" \
"\n" \
+#define CHANGE_ELEMENT_KIND_JS \
+ "// PAC script with getter that changes element kind.\n" \
+ "\n" \
+ "function FindProxyForURL(url, host) {\n" \
+ " let arr = [];\n" \
+ " arr[1000] = 0x1234;\n" \
+ "\n" \
+ " arr.__defineGetter__(256, function () {\n" \
+ " delete arr[256];\n" \
+ " arr.unshift(1.1);\n" \
+ " });\n" \
+ "\n" \
+ " let results = Object.entries(arr);\n" \
+ " let str = results.toString();\n" \
+ " return \"DIRECT\";\n" \
+ "}\n" \
+
#define DIRECT_JS \
"function FindProxyForURL(url, host) {\n" \
" return \"DIRECT\";\n" \