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 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_VALIDATION_UTIL_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_VALIDATION_UTIL_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_VALIDATION_UTIL_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_VALIDATION_UTIL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" | 10 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 BoundsChecker* bounds_checker) { | 109 BoundsChecker* bounds_checker) { |
110 if (!ValidateEncodedPointer(&input.offset)) { | 110 if (!ValidateEncodedPointer(&input.offset)) { |
111 ReportValidationError(VALIDATION_ERROR_ILLEGAL_POINTER); | 111 ReportValidationError(VALIDATION_ERROR_ILLEGAL_POINTER); |
112 return false; | 112 return false; |
113 } | 113 } |
114 | 114 |
115 return T::Validate(DecodePointerRaw(&input.offset), bounds_checker); | 115 return T::Validate(DecodePointerRaw(&input.offset), bounds_checker); |
116 } | 116 } |
117 | 117 |
118 template <typename T> | 118 template <typename T> |
| 119 bool ValidateNative(const NativePointer<T>& input, |
| 120 BoundsChecker* bounds_checker) { |
| 121 if (!ValidateEncodedPointer(&input.offset)) { |
| 122 ReportValidationError(VALIDATION_ERROR_ILLEGAL_POINTER); |
| 123 return false; |
| 124 } |
| 125 |
| 126 // Native types perform validation during deserialization. |
| 127 DecodePointerRaw(&input.offset); |
| 128 return true; |
| 129 } |
| 130 |
| 131 template <typename T> |
119 bool ValidateInlinedUnion(const T& input, BoundsChecker* bounds_checker) { | 132 bool ValidateInlinedUnion(const T& input, BoundsChecker* bounds_checker) { |
120 return T::Validate(&input, bounds_checker, true); | 133 return T::Validate(&input, bounds_checker, true); |
121 } | 134 } |
122 | 135 |
123 bool ValidateHandle(const Handle& input, BoundsChecker* bounds_checker); | 136 bool ValidateHandle(const Handle& input, BoundsChecker* bounds_checker); |
124 | 137 |
125 bool ValidateAssociatedInterfaceId(InterfaceId input); | 138 bool ValidateAssociatedInterfaceId(InterfaceId input); |
126 | 139 |
127 } // namespace internal | 140 } // namespace internal |
128 } // namespace mojo | 141 } // namespace mojo |
129 | 142 |
130 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_VALIDATION_UTIL_H_ | 143 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_VALIDATION_UTIL_H_ |
OLD | NEW |