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

Unified Diff: mojo/edk/system/message_in_transit.cc

Issue 728133002: Update mojo sdk to rev e01f9a49449381a5eb430c1fd88bf2cae73ec35a (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: android + ios gyp fixes Created 6 years, 1 month 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
« no previous file with comments | « mojo/edk/system/memory.cc ('k') | mojo/edk/system/message_pipe.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/message_in_transit.cc
diff --git a/mojo/edk/system/message_in_transit.cc b/mojo/edk/system/message_in_transit.cc
index 95a7d2312ed3ca6a01a24ebc61ec83a5c19216f4..0f2ff5e6e69a4de8e721b5db6ec39ca7c7267d18 100644
--- a/mojo/edk/system/message_in_transit.cc
+++ b/mojo/edk/system/message_in_transit.cc
@@ -8,7 +8,7 @@
#include "base/compiler_specific.h"
#include "base/logging.h"
-#include "mojo/edk/system/constants.h"
+#include "mojo/edk/system/configuration.h"
#include "mojo/edk/system/transport_data.h"
namespace mojo {
@@ -38,23 +38,13 @@ struct MessageInTransit::PrivateStructForCompileAsserts {
// The size of |Header| must be a multiple of the alignment.
static_assert(sizeof(Header) % kMessageAlignment == 0,
"sizeof(MessageInTransit::Header) invalid");
- // Avoid dangerous situations, but making sure that the size of the "header" +
- // the size of the data fits into a 31-bit number.
- static_assert(static_cast<uint64_t>(sizeof(Header)) + kMaxMessageNumBytes <=
- 0x7fffffffULL,
- "kMaxMessageNumBytes too big");
-
- // We assume (to avoid extra rounding code) that the maximum message (data)
- // size is a multiple of the alignment.
- static_assert(kMaxMessageNumBytes % kMessageAlignment == 0,
- "kMessageAlignment not a multiple of alignment");
};
MessageInTransit::View::View(size_t message_size, const void* buffer)
: buffer_(buffer) {
size_t next_message_size = 0;
- DCHECK(MessageInTransit::GetNextMessageSize(
- buffer_, message_size, &next_message_size));
+ DCHECK(MessageInTransit::GetNextMessageSize(buffer_, message_size,
+ &next_message_size));
DCHECK_EQ(message_size, next_message_size);
// This should be equivalent.
DCHECK_EQ(message_size, total_size());
@@ -62,18 +52,29 @@ MessageInTransit::View::View(size_t message_size, const void* buffer)
bool MessageInTransit::View::IsValid(size_t serialized_platform_handle_size,
const char** error_message) const {
+ size_t max_message_num_bytes = GetConfiguration().max_message_num_bytes;
+ // Avoid dangerous situations, but making sure that the size of the "header" +
+ // the size of the data fits into a 31-bit number.
+ DCHECK_LE(static_cast<uint64_t>(sizeof(Header)) + max_message_num_bytes,
+ 0x7fffffffULL)
+ << "GetConfiguration().max_message_num_bytes too big";
+
+ // We assume (to avoid extra rounding code) that the maximum message (data)
+ // size is a multiple of the alignment.
+ DCHECK_EQ(max_message_num_bytes % kMessageAlignment, 0U)
+ << "GetConfiguration().max_message_num_bytes not a multiple of alignment";
+
// Note: This also implies a check on the |main_buffer_size()|, which is just
// |RoundUpMessageAlignment(sizeof(Header) + num_bytes())|.
- if (num_bytes() > kMaxMessageNumBytes) {
+ if (num_bytes() > max_message_num_bytes) {
*error_message = "Message data payload too large";
return false;
}
if (transport_data_buffer_size() > 0) {
- const char* e =
- TransportData::ValidateBuffer(serialized_platform_handle_size,
- transport_data_buffer(),
- transport_data_buffer_size());
+ const char* e = TransportData::ValidateBuffer(
+ serialized_platform_handle_size, transport_data_buffer(),
+ transport_data_buffer_size());
if (e) {
*error_message = e;
return false;
@@ -93,8 +94,7 @@ MessageInTransit::MessageInTransit(Type type,
ConstructorHelper(type, subtype, num_bytes);
if (bytes) {
memcpy(MessageInTransit::bytes(), bytes, num_bytes);
- memset(static_cast<char*>(MessageInTransit::bytes()) + num_bytes,
- 0,
+ memset(static_cast<char*>(MessageInTransit::bytes()) + num_bytes, 0,
main_buffer_size_ - sizeof(Header) - num_bytes);
} else {
memset(MessageInTransit::bytes(), 0, main_buffer_size_ - sizeof(Header));
@@ -195,7 +195,7 @@ void MessageInTransit::SerializeAndCloseDispatchers(Channel* channel) {
void MessageInTransit::ConstructorHelper(Type type,
Subtype subtype,
uint32_t num_bytes) {
- DCHECK_LE(num_bytes, kMaxMessageNumBytes);
+ DCHECK_LE(num_bytes, GetConfiguration().max_message_num_bytes);
// |total_size| is updated below, from the other values.
header()->type = type;
« no previous file with comments | « mojo/edk/system/memory.cc ('k') | mojo/edk/system/message_pipe.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698