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

Side by Side Diff: mojo/public/cpp/bindings/lib/validation_util.cc

Issue 2660733002: Mojo C++ bindings: introduce an optional array to store transferred interface IDs in messages. (Closed)
Patch Set: . Created 3 years, 10 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
« no previous file with comments | « mojo/public/cpp/bindings/lib/validation_util.h ('k') | mojo/public/cpp/bindings/message.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/public/cpp/bindings/lib/validation_util.h" 5 #include "mojo/public/cpp/bindings/lib/validation_util.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <limits> 9 #include <limits>
10 10
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 if (message->has_flag(Message::kFlagExpectsResponse) || 94 if (message->has_flag(Message::kFlagExpectsResponse) ||
95 !message->has_flag(Message::kFlagIsResponse)) { 95 !message->has_flag(Message::kFlagIsResponse)) {
96 ReportValidationError(validation_context, 96 ReportValidationError(validation_context,
97 VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAGS); 97 VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAGS);
98 return false; 98 return false;
99 } 99 }
100 return true; 100 return true;
101 } 101 }
102 102
103 bool IsHandleOrInterfaceValid(const AssociatedInterface_Data& input) { 103 bool IsHandleOrInterfaceValid(const AssociatedInterface_Data& input) {
104 return IsValidInterfaceId(input.interface_id); 104 return input.handle.is_valid();
105 } 105 }
106 106
107 bool IsHandleOrInterfaceValid(const AssociatedInterfaceRequest_Data& input) { 107 bool IsHandleOrInterfaceValid(const AssociatedEndpointHandle_Data& input) {
108 return IsValidInterfaceId(input.interface_id); 108 return input.is_valid();
109 } 109 }
110 110
111 bool IsHandleOrInterfaceValid(const Interface_Data& input) { 111 bool IsHandleOrInterfaceValid(const Interface_Data& input) {
112 return input.handle.is_valid(); 112 return input.handle.is_valid();
113 } 113 }
114 114
115 bool IsHandleOrInterfaceValid(const Handle_Data& input) { 115 bool IsHandleOrInterfaceValid(const Handle_Data& input) {
116 return input.is_valid(); 116 return input.is_valid();
117 } 117 }
118 118
119 bool ValidateHandleOrInterfaceNonNullable( 119 bool ValidateHandleOrInterfaceNonNullable(
120 const AssociatedInterface_Data& input, 120 const AssociatedInterface_Data& input,
121 const char* error_message, 121 const char* error_message,
122 ValidationContext* validation_context) { 122 ValidationContext* validation_context) {
123 if (IsHandleOrInterfaceValid(input)) 123 if (IsHandleOrInterfaceValid(input))
124 return true; 124 return true;
125 125
126 ReportValidationError(validation_context, 126 ReportValidationError(validation_context,
127 VALIDATION_ERROR_UNEXPECTED_INVALID_INTERFACE_ID, 127 VALIDATION_ERROR_UNEXPECTED_INVALID_INTERFACE_ID,
128 error_message); 128 error_message);
129 return false; 129 return false;
130 } 130 }
131 131
132 bool ValidateHandleOrInterfaceNonNullable( 132 bool ValidateHandleOrInterfaceNonNullable(
133 const AssociatedInterfaceRequest_Data& input, 133 const AssociatedEndpointHandle_Data& input,
134 const char* error_message, 134 const char* error_message,
135 ValidationContext* validation_context) { 135 ValidationContext* validation_context) {
136 if (IsHandleOrInterfaceValid(input)) 136 if (IsHandleOrInterfaceValid(input))
137 return true; 137 return true;
138 138
139 ReportValidationError(validation_context, 139 ReportValidationError(validation_context,
140 VALIDATION_ERROR_UNEXPECTED_INVALID_INTERFACE_ID, 140 VALIDATION_ERROR_UNEXPECTED_INVALID_INTERFACE_ID,
141 error_message); 141 error_message);
142 return false; 142 return false;
143 } 143 }
(...skipping 19 matching lines...) Expand all
163 return true; 163 return true;
164 164
165 ReportValidationError(validation_context, 165 ReportValidationError(validation_context,
166 VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE, 166 VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE,
167 error_message); 167 error_message);
168 return false; 168 return false;
169 } 169 }
170 170
171 bool ValidateHandleOrInterface(const AssociatedInterface_Data& input, 171 bool ValidateHandleOrInterface(const AssociatedInterface_Data& input,
172 ValidationContext* validation_context) { 172 ValidationContext* validation_context) {
173 if (!IsMasterInterfaceId(input.interface_id)) 173 if (validation_context->ClaimAssociatedEndpointHandle(input.handle))
174 return true; 174 return true;
175 175
176 ReportValidationError(validation_context, 176 ReportValidationError(validation_context,
177 VALIDATION_ERROR_ILLEGAL_INTERFACE_ID); 177 VALIDATION_ERROR_ILLEGAL_INTERFACE_ID);
178 return false; 178 return false;
179 } 179 }
180 180
181 bool ValidateHandleOrInterface(const AssociatedInterfaceRequest_Data& input, 181 bool ValidateHandleOrInterface(const AssociatedEndpointHandle_Data& input,
182 ValidationContext* validation_context) { 182 ValidationContext* validation_context) {
183 if (!IsMasterInterfaceId(input.interface_id)) 183 if (validation_context->ClaimAssociatedEndpointHandle(input))
184 return true; 184 return true;
185 185
186 ReportValidationError(validation_context, 186 ReportValidationError(validation_context,
187 VALIDATION_ERROR_ILLEGAL_INTERFACE_ID); 187 VALIDATION_ERROR_ILLEGAL_INTERFACE_ID);
188 return false; 188 return false;
189 } 189 }
190 190
191 bool ValidateHandleOrInterface(const Interface_Data& input, 191 bool ValidateHandleOrInterface(const Interface_Data& input,
192 ValidationContext* validation_context) { 192 ValidationContext* validation_context) {
193 if (validation_context->ClaimHandle(input.handle)) 193 if (validation_context->ClaimHandle(input.handle))
194 return true; 194 return true;
195 195
196 ReportValidationError(validation_context, VALIDATION_ERROR_ILLEGAL_HANDLE); 196 ReportValidationError(validation_context, VALIDATION_ERROR_ILLEGAL_HANDLE);
197 return false; 197 return false;
198 } 198 }
199 199
200 bool ValidateHandleOrInterface(const Handle_Data& input, 200 bool ValidateHandleOrInterface(const Handle_Data& input,
201 ValidationContext* validation_context) { 201 ValidationContext* validation_context) {
202 if (validation_context->ClaimHandle(input)) 202 if (validation_context->ClaimHandle(input))
203 return true; 203 return true;
204 204
205 ReportValidationError(validation_context, VALIDATION_ERROR_ILLEGAL_HANDLE); 205 ReportValidationError(validation_context, VALIDATION_ERROR_ILLEGAL_HANDLE);
206 return false; 206 return false;
207 } 207 }
208 208
209 } // namespace internal 209 } // namespace internal
210 } // namespace mojo 210 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/validation_util.h ('k') | mojo/public/cpp/bindings/message.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698