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 <limits> | 7 #include <limits> |
8 | 8 |
9 #include "mojo/public/cpp/bindings/lib/bindings_serialization.h" | 9 #include "mojo/public/cpp/bindings/lib/bindings_serialization.h" |
10 #include "mojo/public/cpp/bindings/lib/message_internal.h" | 10 #include "mojo/public/cpp/bindings/lib/message_internal.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 bool ValidateControlResponse(const Message* message) { | 92 bool ValidateControlResponse(const Message* message) { |
93 if (!ValidateMessageIsResponse(message)) | 93 if (!ValidateMessageIsResponse(message)) |
94 return false; | 94 return false; |
95 switch (message->header()->name) { | 95 switch (message->header()->name) { |
96 case kRunMessageId: | 96 case kRunMessageId: |
97 return ValidateMessagePayload<RunResponseMessageParams_Data>(message); | 97 return ValidateMessagePayload<RunResponseMessageParams_Data>(message); |
98 } | 98 } |
99 return false; | 99 return false; |
100 } | 100 } |
101 | 101 |
| 102 bool ValidateHandleNonNullable(const Handle& input, const char* error_message) { |
| 103 if (input.value() != kEncodedInvalidHandleValue) |
| 104 return true; |
| 105 |
| 106 ReportValidationError(VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE, |
| 107 error_message); |
| 108 return false; |
| 109 } |
| 110 |
| 111 bool ValidateInterfaceIdNonNullable(InterfaceId input, |
| 112 const char* error_message) { |
| 113 if (IsValidInterfaceId(input)) |
| 114 return true; |
| 115 |
| 116 ReportValidationError(VALIDATION_ERROR_UNEXPECTED_INVALID_INTERFACE_ID, |
| 117 error_message); |
| 118 return false; |
| 119 } |
| 120 |
| 121 bool ValidateHandle(const Handle& input, BoundsChecker* bounds_checker) { |
| 122 if (bounds_checker->ClaimHandle(input)) |
| 123 return true; |
| 124 |
| 125 ReportValidationError(VALIDATION_ERROR_ILLEGAL_HANDLE); |
| 126 return false; |
| 127 } |
| 128 |
| 129 bool ValidateAssociatedInterfaceId(InterfaceId input) { |
| 130 if (!IsMasterInterfaceId(input)) |
| 131 return true; |
| 132 |
| 133 ReportValidationError(VALIDATION_ERROR_ILLEGAL_INTERFACE_ID); |
| 134 return false; |
| 135 } |
| 136 |
102 } // namespace internal | 137 } // namespace internal |
103 } // namespace mojo | 138 } // namespace mojo |
OLD | NEW |