OLD | NEW |
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 ValidationContext* validation_context) { | 93 ValidationContext* validation_context) { |
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 ValidateControlRequest(const Message* message, | |
104 ValidationContext* validation_context) { | |
105 switch (message->header()->name) { | |
106 case interface_control::kRunMessageId: | |
107 return ValidateMessageIsRequestExpectingResponse(message, | |
108 validation_context) && | |
109 ValidateMessagePayload< | |
110 interface_control::internal::RunMessageParams_Data>( | |
111 message, validation_context); | |
112 case interface_control::kRunOrClosePipeMessageId: | |
113 return ValidateMessageIsRequestWithoutResponse(message, | |
114 validation_context) && | |
115 ValidateMessagePayload< | |
116 interface_control::internal::RunOrClosePipeMessageParams_Data>( | |
117 message, validation_context); | |
118 } | |
119 return false; | |
120 } | |
121 | |
122 bool ValidateControlResponse(const Message* message, | |
123 ValidationContext* validation_context) { | |
124 if (!ValidateMessageIsResponse(message, validation_context)) | |
125 return false; | |
126 switch (message->header()->name) { | |
127 case interface_control::kRunMessageId: | |
128 return ValidateMessagePayload< | |
129 interface_control::internal::RunResponseMessageParams_Data>( | |
130 message, validation_context); | |
131 } | |
132 return false; | |
133 } | |
134 | |
135 bool IsHandleOrInterfaceValid(const AssociatedInterface_Data& input) { | 103 bool IsHandleOrInterfaceValid(const AssociatedInterface_Data& input) { |
136 return IsValidInterfaceId(input.interface_id); | 104 return IsValidInterfaceId(input.interface_id); |
137 } | 105 } |
138 | 106 |
139 bool IsHandleOrInterfaceValid(const AssociatedInterfaceRequest_Data& input) { | 107 bool IsHandleOrInterfaceValid(const AssociatedInterfaceRequest_Data& input) { |
140 return IsValidInterfaceId(input.interface_id); | 108 return IsValidInterfaceId(input.interface_id); |
141 } | 109 } |
142 | 110 |
143 bool IsHandleOrInterfaceValid(const Interface_Data& input) { | 111 bool IsHandleOrInterfaceValid(const Interface_Data& input) { |
144 return input.handle.is_valid(); | 112 return input.handle.is_valid(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 ValidationContext* validation_context) { | 201 ValidationContext* validation_context) { |
234 if (validation_context->ClaimHandle(input)) | 202 if (validation_context->ClaimHandle(input)) |
235 return true; | 203 return true; |
236 | 204 |
237 ReportValidationError(validation_context, VALIDATION_ERROR_ILLEGAL_HANDLE); | 205 ReportValidationError(validation_context, VALIDATION_ERROR_ILLEGAL_HANDLE); |
238 return false; | 206 return false; |
239 } | 207 } |
240 | 208 |
241 } // namespace internal | 209 } // namespace internal |
242 } // namespace mojo | 210 } // namespace mojo |
OLD | NEW |