OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/message_header_validator.h" | 5 #include "mojo/public/cpp/bindings/message_header_validator.h" |
6 | 6 |
7 #include "mojo/public/cpp/bindings/lib/array_internal.h" | 7 #include "mojo/public/cpp/bindings/lib/array_internal.h" |
8 #include "mojo/public/cpp/bindings/lib/validate_params.h" | 8 #include "mojo/public/cpp/bindings/lib/validate_params.h" |
9 #include "mojo/public/cpp/bindings/lib/validation_context.h" | 9 #include "mojo/public/cpp/bindings/lib/validation_context.h" |
10 #include "mojo/public/cpp/bindings/lib/validation_errors.h" | 10 #include "mojo/public/cpp/bindings/lib/validation_errors.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 if ((header->flags & kRequestIdFlags) == kRequestIdFlags) { | 57 if ((header->flags & kRequestIdFlags) == kRequestIdFlags) { |
58 internal::ReportValidationError( | 58 internal::ReportValidationError( |
59 validation_context, | 59 validation_context, |
60 internal::VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAGS); | 60 internal::VALIDATION_ERROR_MESSAGE_HEADER_INVALID_FLAGS); |
61 return false; | 61 return false; |
62 } | 62 } |
63 | 63 |
64 if (header->version < 2) | 64 if (header->version < 2) |
65 return true; | 65 return true; |
66 | 66 |
67 auto header_v2 = static_cast<const internal::MessageHeaderV2*>(header); | 67 auto* header_v2 = static_cast<const internal::MessageHeaderV2*>(header); |
68 // For the payload pointer: | 68 // For the payload pointer: |
69 // - Check that the pointer can be safely decoded. | 69 // - Check that the pointer can be safely decoded. |
70 // - Claim one byte that the pointer points to. It makes sure not only the | 70 // - Claim one byte that the pointer points to. It makes sure not only the |
71 // address is within the message, but also the address precedes the array | 71 // address is within the message, but also the address precedes the array |
72 // storing interface IDs (which is important for safely calculating the | 72 // storing interface IDs (which is important for safely calculating the |
73 // payload size). | 73 // payload size). |
74 // - Validation of the payload contents will be done separately based on the | 74 // - Validation of the payload contents will be done separately based on the |
75 // payload type. | 75 // payload type. |
76 if (!header_v2->payload.is_null() && | 76 if (!header_v2->payload.is_null() && |
77 (!internal::ValidatePointer(header_v2->payload, validation_context) || | 77 (!internal::ValidatePointer(header_v2->payload, validation_context) || |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 &validation_context)) | 124 &validation_context)) |
125 return false; | 125 return false; |
126 | 126 |
127 if (!IsValidMessageHeader(message->header(), &validation_context)) | 127 if (!IsValidMessageHeader(message->header(), &validation_context)) |
128 return false; | 128 return false; |
129 | 129 |
130 return true; | 130 return true; |
131 } | 131 } |
132 | 132 |
133 } // namespace mojo | 133 } // namespace mojo |
OLD | NEW |