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

Unified Diff: mojo/public/cpp/bindings/lib/validation_util.cc

Issue 1486573003: Mojo C++ bindings: associated interface pointers/requests validation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/cpp/bindings/lib/validation_util.cc
diff --git a/mojo/public/cpp/bindings/lib/validation_util.cc b/mojo/public/cpp/bindings/lib/validation_util.cc
index 2268a159edd4ee4286ecf36a8e30808bbe10eec3..3051c1c2368eb9d3a213dec457823c725e6dd00b 100644
--- a/mojo/public/cpp/bindings/lib/validation_util.cc
+++ b/mojo/public/cpp/bindings/lib/validation_util.cc
@@ -99,5 +99,40 @@ bool ValidateControlResponse(const Message* message) {
return false;
}
+bool ValidateHandleNonNullable(const Handle& input, const char* error_message) {
+ if (input.value() != kEncodedInvalidHandleValue)
+ return true;
+
+ ReportValidationError(VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE,
+ error_message);
+ return false;
+}
+
+bool ValidateInterfaceIdNonNullable(InterfaceId input,
+ const char* error_message) {
+ if (IsValidInterfaceId(input))
+ return true;
+
+ ReportValidationError(VALIDATION_ERROR_UNEXPECTED_INVALID_INTERFACE_ID,
+ error_message);
+ return false;
+}
+
+bool ValidateHandle(const Handle& input, BoundsChecker* bounds_checker) {
+ if (bounds_checker->ClaimHandle(input))
+ return true;
+
+ ReportValidationError(VALIDATION_ERROR_ILLEGAL_HANDLE);
+ return false;
+}
+
+bool ValidateAssociatedInterfaceId(InterfaceId input) {
+ if (!IsMasterInterfaceId(input))
+ return true;
+
+ ReportValidationError(VALIDATION_ERROR_ILLEGAL_INTERFACE_ID);
+ return false;
+}
+
} // namespace internal
} // namespace mojo
« no previous file with comments | « mojo/public/cpp/bindings/lib/validation_util.h ('k') | mojo/public/cpp/bindings/tests/validation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698