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

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

Issue 2064903002: Mojo: Report bindings validation errors via MojoNotifyBadMessage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/cpp/bindings/lib/pipe_control_message_handler.cc
diff --git a/mojo/public/cpp/bindings/lib/pipe_control_message_handler.cc b/mojo/public/cpp/bindings/lib/pipe_control_message_handler.cc
index ae952c503f2e33f31181c30363e56311e80491ee..1a8b087123d5e5201efc6213a023eea0a4a2dcd0 100644
--- a/mojo/public/cpp/bindings/lib/pipe_control_message_handler.cc
+++ b/mojo/public/cpp/bindings/lib/pipe_control_message_handler.cc
@@ -8,6 +8,7 @@
#include "mojo/public/cpp/bindings/lib/message_builder.h"
#include "mojo/public/cpp/bindings/lib/pipe_control_message_handler_delegate.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"
+#include "mojo/public/cpp/bindings/lib/validation_context.h"
#include "mojo/public/cpp/bindings/lib/validation_util.h"
#include "mojo/public/interfaces/bindings/pipe_control_messages.mojom.h"
@@ -20,6 +21,10 @@ PipeControlMessageHandler::PipeControlMessageHandler(
PipeControlMessageHandler::~PipeControlMessageHandler() {}
+void PipeControlMessageHandler::SetDescription(const std::string& description) {
+ description_ = description;
+}
+
// static
bool PipeControlMessageHandler::IsPipeControlMessage(const Message* message) {
return !IsValidInterfaceId(message->interface_id());
@@ -36,12 +41,16 @@ bool PipeControlMessageHandler::Accept(Message* message) {
return false;
}
-bool PipeControlMessageHandler::Validate(const Message* message) {
+bool PipeControlMessageHandler::Validate(Message* message) {
+ ValidationContext validation_context(
+ message->data(), message->data_num_bytes(), 0, message, description_);
+
if (message->name() == pipe_control::kRunOrClosePipeMessageId) {
- if (!ValidateMessageIsRequestWithoutResponse(message))
+ if (!ValidateMessageIsRequestWithoutResponse(message, &validation_context))
return false;
return ValidateMessagePayload<
- pipe_control::internal::RunOrClosePipeMessageParams_Data>(message);
+ pipe_control::internal::RunOrClosePipeMessageParams_Data>(
+ message, &validation_context);
}
return false;

Powered by Google App Engine
This is Rietveld 408576698