Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Unified Diff: third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl

Issue 1526183004: Prevent SharedArrayBuffer views from being used in bindings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: some tests Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl
diff --git a/third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl b/third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl
index a0a47790a96e7f346169d1d677a97245f556c1f6..a6b5ad29cf73dcd0e7237b4811bfe378f73aeb12 100644
--- a/third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl
+++ b/third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl
@@ -233,6 +233,30 @@ if (!{{argument.name}}.isUndefinedOrNull() && !{{argument.name}}.isObject()) {
return;
}
{% endif %}
+{% if argument.is_array_buffer_view %}
+if ({{argument.name}}{% if argument.is_flexible_array_buffer_view %}.{% else %}->{% endif %}isShared()) {
+ {{throw_type_error(method,
+ '"parameter %s is a view of a SharedArrayBuffer."' %
+ (argument.index + 1)) | indent}}
+ return;
+}
+{% elif argument.is_union_with_array_buffer_view %}
+if ({{argument.name}}.isArrayBufferView() && {{argument.name}}.getAsArrayBufferView()->isShared()) {
+ {{throw_type_error(method,
+ '"parameter %s is a view of a SharedArrayBuffer."' %
+ (argument.index + 1)) | indent}}
+ return;
+}
+{% elif argument.is_sequence_of_union_with_array_buffer_view %}
+for (size_t i= 0; i < {{argument.name}}.size(); ++i) {
+ if ({{argument.name}}[i].isArrayBufferView() && {{argument.name}}[i].getAsArrayBufferView()->isShared()) {
+ {{throw_type_error(method,
+ '"sequence parameter %s contains a view of a SharedArrayBuffer."' %
+ (argument.index + 1)) | indent(8)}}
+ return;
+ }
+}
+{% endif %}
{% endmacro %}

Powered by Google App Engine
This is Rietveld 408576698