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

Side by Side Diff: mojo/public/tools/bindings/generators/cpp_templates/struct_definition.tmpl

Issue 2312813002: Limit Mojo messages recursion depth (Closed)
Patch Set: Update comment to match arg name change Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 {%- import "validation_macros.tmpl" as validation_macros %} 1 {%- import "validation_macros.tmpl" as validation_macros %}
2 {%- set class_name = struct.name ~ "_Data" %} 2 {%- set class_name = struct.name ~ "_Data" %}
3 3
4 // static 4 // static
5 bool {{class_name}}::Validate( 5 bool {{class_name}}::Validate(
6 const void* data, 6 const void* data,
7 mojo::internal::ValidationContext* validation_context) { 7 mojo::internal::ValidationContext* validation_context) {
8 mojo::internal::ValidationContext::ScopedDepthTracker depth_tracker(
yzshen1 2016/09/06 17:03:10 This is not the only place: we need to consider th
tibell 2016/09/07 05:41:20 Done. I was aware of this. The reason I didn't do
9 validation_context);
10 if (validation_context->ExceedsMaxDepth()) {
11 ReportValidationError(
12 validation_context,
13 mojo::internal::VALIDATION_ERROR_MAX_RECURSION_DEPTH);
14 return false;
15 }
16
8 if (!data) 17 if (!data)
9 return true; 18 return true;
10 19
11 if (!ValidateStructHeaderAndClaimMemory(data, validation_context)) 20 if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
12 return false; 21 return false;
13 22
14 // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if 23 // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
15 // the message comes from an older version. 24 // the message comes from an older version.
16 const {{class_name}}* object = static_cast<const {{class_name}}*>(data); 25 const {{class_name}}* object = static_cast<const {{class_name}}*>(data);
17 26
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 return true; 70 return true;
62 {%- endif %} 71 {%- endif %}
63 {%- set field_expr = "object->" ~ packed_field.field.name %} 72 {%- set field_expr = "object->" ~ packed_field.field.name %}
64 {{validation_macros.validate_field(packed_field.field, field_expr, struct.name, true)}} 73 {{validation_macros.validate_field(packed_field.field, field_expr, struct.name, true)}}
65 {%- endif %} 74 {%- endif %}
66 {%- endfor %} 75 {%- endfor %}
67 76
68 return true; 77 return true;
69 } 78 }
70 79
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698