807 lines
26 KiB
C++
Executable File
807 lines
26 KiB
C++
Executable File
// Copyright 2016 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#if defined(_MSC_VER)
|
|
#pragma warning(push)
|
|
#pragma warning(disable:4065)
|
|
#endif
|
|
|
|
#include "chrome/common/plugin.mojom-shared.h"
|
|
|
|
#include <utility>
|
|
|
|
#include "base/logging.h"
|
|
#include "mojo/public/cpp/bindings/lib/validate_params.h"
|
|
#include "mojo/public/cpp/bindings/lib/validation_context.h"
|
|
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
|
|
#include "mojo/public/cpp/bindings/lib/validation_util.h"
|
|
namespace chrome {
|
|
namespace mojom {
|
|
|
|
namespace internal {
|
|
|
|
|
|
// static
|
|
bool PluginInfo_Data::Validate(
|
|
const void* data,
|
|
mojo::internal::ValidationContext* validation_context) {
|
|
if (!data)
|
|
return true;
|
|
|
|
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
|
|
return false;
|
|
|
|
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
|
|
// the message comes from an older version.
|
|
const PluginInfo_Data* object = static_cast<const PluginInfo_Data*>(data);
|
|
|
|
static constexpr struct {
|
|
uint32_t version;
|
|
uint32_t num_bytes;
|
|
} kVersionSizes[] = {{ 0, 48 }};
|
|
|
|
if (object->header_.version <=
|
|
kVersionSizes[arraysize(kVersionSizes) - 1].version) {
|
|
// Scan in reverse order to optimize for more recent versions.
|
|
for (int i = arraysize(kVersionSizes) - 1; i >= 0; --i) {
|
|
if (object->header_.version >= kVersionSizes[i].version) {
|
|
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
|
|
break;
|
|
|
|
ReportValidationError(
|
|
validation_context,
|
|
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
|
|
return false;
|
|
}
|
|
}
|
|
} else if (object->header_.num_bytes <
|
|
kVersionSizes[arraysize(kVersionSizes) - 1].num_bytes) {
|
|
ReportValidationError(
|
|
validation_context,
|
|
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
|
|
return false;
|
|
}
|
|
|
|
|
|
if (!::chrome::mojom::internal::PluginStatus_Data
|
|
::Validate(object->status, validation_context))
|
|
return false;
|
|
|
|
if (!mojo::internal::ValidatePointerNonNullable(
|
|
object->plugin, 2, validation_context)) {
|
|
return false;
|
|
}
|
|
if (!mojo::internal::ValidateStruct(object->plugin, validation_context))
|
|
return false;
|
|
|
|
if (!mojo::internal::ValidatePointerNonNullable(
|
|
object->actual_mime_type, 3, validation_context)) {
|
|
return false;
|
|
}
|
|
const mojo::internal::ContainerValidateParams actual_mime_type_validate_params(
|
|
0, false, nullptr);
|
|
if (!mojo::internal::ValidateContainer(object->actual_mime_type, validation_context,
|
|
&actual_mime_type_validate_params)) {
|
|
return false;
|
|
}
|
|
|
|
if (!mojo::internal::ValidatePointerNonNullable(
|
|
object->group_identifier, 4, validation_context)) {
|
|
return false;
|
|
}
|
|
const mojo::internal::ContainerValidateParams group_identifier_validate_params(
|
|
0, false, nullptr);
|
|
if (!mojo::internal::ValidateContainer(object->group_identifier, validation_context,
|
|
&group_identifier_validate_params)) {
|
|
return false;
|
|
}
|
|
|
|
if (!mojo::internal::ValidatePointerNonNullable(
|
|
object->group_name, 5, validation_context)) {
|
|
return false;
|
|
}
|
|
if (!mojo::internal::ValidateStruct(object->group_name, validation_context))
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
PluginInfo_Data::PluginInfo_Data()
|
|
: header_({sizeof(*this), 0}) {}
|
|
|
|
|
|
// static
|
|
bool PluginParam_Data::Validate(
|
|
const void* data,
|
|
mojo::internal::ValidationContext* validation_context) {
|
|
if (!data)
|
|
return true;
|
|
|
|
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
|
|
return false;
|
|
|
|
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
|
|
// the message comes from an older version.
|
|
const PluginParam_Data* object = static_cast<const PluginParam_Data*>(data);
|
|
|
|
static constexpr struct {
|
|
uint32_t version;
|
|
uint32_t num_bytes;
|
|
} kVersionSizes[] = {{ 0, 24 }};
|
|
|
|
if (object->header_.version <=
|
|
kVersionSizes[arraysize(kVersionSizes) - 1].version) {
|
|
// Scan in reverse order to optimize for more recent versions.
|
|
for (int i = arraysize(kVersionSizes) - 1; i >= 0; --i) {
|
|
if (object->header_.version >= kVersionSizes[i].version) {
|
|
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
|
|
break;
|
|
|
|
ReportValidationError(
|
|
validation_context,
|
|
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
|
|
return false;
|
|
}
|
|
}
|
|
} else if (object->header_.num_bytes <
|
|
kVersionSizes[arraysize(kVersionSizes) - 1].num_bytes) {
|
|
ReportValidationError(
|
|
validation_context,
|
|
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
|
|
return false;
|
|
}
|
|
|
|
if (!mojo::internal::ValidatePointerNonNullable(
|
|
object->name, 1, validation_context)) {
|
|
return false;
|
|
}
|
|
if (!mojo::internal::ValidateStruct(object->name, validation_context))
|
|
return false;
|
|
|
|
if (!mojo::internal::ValidatePointerNonNullable(
|
|
object->value, 2, validation_context)) {
|
|
return false;
|
|
}
|
|
if (!mojo::internal::ValidateStruct(object->value, validation_context))
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
PluginParam_Data::PluginParam_Data()
|
|
: header_({sizeof(*this), 0}) {}
|
|
|
|
|
|
// static
|
|
bool PluginHost_ShowFlashPermissionBubble_Params_Data::Validate(
|
|
const void* data,
|
|
mojo::internal::ValidationContext* validation_context) {
|
|
if (!data)
|
|
return true;
|
|
|
|
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
|
|
return false;
|
|
|
|
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
|
|
// the message comes from an older version.
|
|
const PluginHost_ShowFlashPermissionBubble_Params_Data* object = static_cast<const PluginHost_ShowFlashPermissionBubble_Params_Data*>(data);
|
|
|
|
static constexpr struct {
|
|
uint32_t version;
|
|
uint32_t num_bytes;
|
|
} kVersionSizes[] = {{ 0, 8 }};
|
|
|
|
if (object->header_.version <=
|
|
kVersionSizes[arraysize(kVersionSizes) - 1].version) {
|
|
// Scan in reverse order to optimize for more recent versions.
|
|
for (int i = arraysize(kVersionSizes) - 1; i >= 0; --i) {
|
|
if (object->header_.version >= kVersionSizes[i].version) {
|
|
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
|
|
break;
|
|
|
|
ReportValidationError(
|
|
validation_context,
|
|
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
|
|
return false;
|
|
}
|
|
}
|
|
} else if (object->header_.num_bytes <
|
|
kVersionSizes[arraysize(kVersionSizes) - 1].num_bytes) {
|
|
ReportValidationError(
|
|
validation_context,
|
|
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
PluginHost_ShowFlashPermissionBubble_Params_Data::PluginHost_ShowFlashPermissionBubble_Params_Data()
|
|
: header_({sizeof(*this), 0}) {}
|
|
|
|
|
|
// static
|
|
bool PluginHost_CouldNotLoadPlugin_Params_Data::Validate(
|
|
const void* data,
|
|
mojo::internal::ValidationContext* validation_context) {
|
|
if (!data)
|
|
return true;
|
|
|
|
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
|
|
return false;
|
|
|
|
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
|
|
// the message comes from an older version.
|
|
const PluginHost_CouldNotLoadPlugin_Params_Data* object = static_cast<const PluginHost_CouldNotLoadPlugin_Params_Data*>(data);
|
|
|
|
static constexpr struct {
|
|
uint32_t version;
|
|
uint32_t num_bytes;
|
|
} kVersionSizes[] = {{ 0, 16 }};
|
|
|
|
if (object->header_.version <=
|
|
kVersionSizes[arraysize(kVersionSizes) - 1].version) {
|
|
// Scan in reverse order to optimize for more recent versions.
|
|
for (int i = arraysize(kVersionSizes) - 1; i >= 0; --i) {
|
|
if (object->header_.version >= kVersionSizes[i].version) {
|
|
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
|
|
break;
|
|
|
|
ReportValidationError(
|
|
validation_context,
|
|
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
|
|
return false;
|
|
}
|
|
}
|
|
} else if (object->header_.num_bytes <
|
|
kVersionSizes[arraysize(kVersionSizes) - 1].num_bytes) {
|
|
ReportValidationError(
|
|
validation_context,
|
|
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
|
|
return false;
|
|
}
|
|
|
|
if (!mojo::internal::ValidatePointerNonNullable(
|
|
object->file_path, 1, validation_context)) {
|
|
return false;
|
|
}
|
|
if (!mojo::internal::ValidateStruct(object->file_path, validation_context))
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
PluginHost_CouldNotLoadPlugin_Params_Data::PluginHost_CouldNotLoadPlugin_Params_Data()
|
|
: header_({sizeof(*this), 0}) {}
|
|
|
|
|
|
// static
|
|
bool PluginHost_BlockedOutdatedPlugin_Params_Data::Validate(
|
|
const void* data,
|
|
mojo::internal::ValidationContext* validation_context) {
|
|
if (!data)
|
|
return true;
|
|
|
|
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
|
|
return false;
|
|
|
|
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
|
|
// the message comes from an older version.
|
|
const PluginHost_BlockedOutdatedPlugin_Params_Data* object = static_cast<const PluginHost_BlockedOutdatedPlugin_Params_Data*>(data);
|
|
|
|
static constexpr struct {
|
|
uint32_t version;
|
|
uint32_t num_bytes;
|
|
} kVersionSizes[] = {{ 0, 24 }};
|
|
|
|
if (object->header_.version <=
|
|
kVersionSizes[arraysize(kVersionSizes) - 1].version) {
|
|
// Scan in reverse order to optimize for more recent versions.
|
|
for (int i = arraysize(kVersionSizes) - 1; i >= 0; --i) {
|
|
if (object->header_.version >= kVersionSizes[i].version) {
|
|
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
|
|
break;
|
|
|
|
ReportValidationError(
|
|
validation_context,
|
|
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
|
|
return false;
|
|
}
|
|
}
|
|
} else if (object->header_.num_bytes <
|
|
kVersionSizes[arraysize(kVersionSizes) - 1].num_bytes) {
|
|
ReportValidationError(
|
|
validation_context,
|
|
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
|
|
return false;
|
|
}
|
|
|
|
if (!mojo::internal::ValidateHandleOrInterfaceNonNullable(
|
|
object->plugin_renderer, 1, validation_context)) {
|
|
return false;
|
|
}
|
|
if (!mojo::internal::ValidateHandleOrInterface(object->plugin_renderer,
|
|
validation_context)) {
|
|
return false;
|
|
}
|
|
|
|
if (!mojo::internal::ValidatePointerNonNullable(
|
|
object->group_id, 2, validation_context)) {
|
|
return false;
|
|
}
|
|
const mojo::internal::ContainerValidateParams group_id_validate_params(
|
|
0, false, nullptr);
|
|
if (!mojo::internal::ValidateContainer(object->group_id, validation_context,
|
|
&group_id_validate_params)) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
PluginHost_BlockedOutdatedPlugin_Params_Data::PluginHost_BlockedOutdatedPlugin_Params_Data()
|
|
: header_({sizeof(*this), 0}) {}
|
|
|
|
|
|
// static
|
|
bool PluginHost_BlockedComponentUpdatedPlugin_Params_Data::Validate(
|
|
const void* data,
|
|
mojo::internal::ValidationContext* validation_context) {
|
|
if (!data)
|
|
return true;
|
|
|
|
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
|
|
return false;
|
|
|
|
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
|
|
// the message comes from an older version.
|
|
const PluginHost_BlockedComponentUpdatedPlugin_Params_Data* object = static_cast<const PluginHost_BlockedComponentUpdatedPlugin_Params_Data*>(data);
|
|
|
|
static constexpr struct {
|
|
uint32_t version;
|
|
uint32_t num_bytes;
|
|
} kVersionSizes[] = {{ 0, 24 }};
|
|
|
|
if (object->header_.version <=
|
|
kVersionSizes[arraysize(kVersionSizes) - 1].version) {
|
|
// Scan in reverse order to optimize for more recent versions.
|
|
for (int i = arraysize(kVersionSizes) - 1; i >= 0; --i) {
|
|
if (object->header_.version >= kVersionSizes[i].version) {
|
|
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
|
|
break;
|
|
|
|
ReportValidationError(
|
|
validation_context,
|
|
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
|
|
return false;
|
|
}
|
|
}
|
|
} else if (object->header_.num_bytes <
|
|
kVersionSizes[arraysize(kVersionSizes) - 1].num_bytes) {
|
|
ReportValidationError(
|
|
validation_context,
|
|
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
|
|
return false;
|
|
}
|
|
|
|
if (!mojo::internal::ValidateHandleOrInterfaceNonNullable(
|
|
object->plugin_renderer, 1, validation_context)) {
|
|
return false;
|
|
}
|
|
if (!mojo::internal::ValidateHandleOrInterface(object->plugin_renderer,
|
|
validation_context)) {
|
|
return false;
|
|
}
|
|
|
|
if (!mojo::internal::ValidatePointerNonNullable(
|
|
object->group_id, 2, validation_context)) {
|
|
return false;
|
|
}
|
|
const mojo::internal::ContainerValidateParams group_id_validate_params(
|
|
0, false, nullptr);
|
|
if (!mojo::internal::ValidateContainer(object->group_id, validation_context,
|
|
&group_id_validate_params)) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
PluginHost_BlockedComponentUpdatedPlugin_Params_Data::PluginHost_BlockedComponentUpdatedPlugin_Params_Data()
|
|
: header_({sizeof(*this), 0}) {}
|
|
|
|
|
|
// static
|
|
bool PluginAuthHost_BlockedUnauthorizedPlugin_Params_Data::Validate(
|
|
const void* data,
|
|
mojo::internal::ValidationContext* validation_context) {
|
|
if (!data)
|
|
return true;
|
|
|
|
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
|
|
return false;
|
|
|
|
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
|
|
// the message comes from an older version.
|
|
const PluginAuthHost_BlockedUnauthorizedPlugin_Params_Data* object = static_cast<const PluginAuthHost_BlockedUnauthorizedPlugin_Params_Data*>(data);
|
|
|
|
static constexpr struct {
|
|
uint32_t version;
|
|
uint32_t num_bytes;
|
|
} kVersionSizes[] = {{ 0, 24 }};
|
|
|
|
if (object->header_.version <=
|
|
kVersionSizes[arraysize(kVersionSizes) - 1].version) {
|
|
// Scan in reverse order to optimize for more recent versions.
|
|
for (int i = arraysize(kVersionSizes) - 1; i >= 0; --i) {
|
|
if (object->header_.version >= kVersionSizes[i].version) {
|
|
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
|
|
break;
|
|
|
|
ReportValidationError(
|
|
validation_context,
|
|
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
|
|
return false;
|
|
}
|
|
}
|
|
} else if (object->header_.num_bytes <
|
|
kVersionSizes[arraysize(kVersionSizes) - 1].num_bytes) {
|
|
ReportValidationError(
|
|
validation_context,
|
|
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
|
|
return false;
|
|
}
|
|
|
|
if (!mojo::internal::ValidatePointerNonNullable(
|
|
object->name, 1, validation_context)) {
|
|
return false;
|
|
}
|
|
if (!mojo::internal::ValidateStruct(object->name, validation_context))
|
|
return false;
|
|
|
|
if (!mojo::internal::ValidatePointerNonNullable(
|
|
object->group_id, 2, validation_context)) {
|
|
return false;
|
|
}
|
|
const mojo::internal::ContainerValidateParams group_id_validate_params(
|
|
0, false, nullptr);
|
|
if (!mojo::internal::ValidateContainer(object->group_id, validation_context,
|
|
&group_id_validate_params)) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
PluginAuthHost_BlockedUnauthorizedPlugin_Params_Data::PluginAuthHost_BlockedUnauthorizedPlugin_Params_Data()
|
|
: header_({sizeof(*this), 0}) {}
|
|
|
|
|
|
// static
|
|
bool PluginInfoHost_GetPluginInfo_Params_Data::Validate(
|
|
const void* data,
|
|
mojo::internal::ValidationContext* validation_context) {
|
|
if (!data)
|
|
return true;
|
|
|
|
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
|
|
return false;
|
|
|
|
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
|
|
// the message comes from an older version.
|
|
const PluginInfoHost_GetPluginInfo_Params_Data* object = static_cast<const PluginInfoHost_GetPluginInfo_Params_Data*>(data);
|
|
|
|
static constexpr struct {
|
|
uint32_t version;
|
|
uint32_t num_bytes;
|
|
} kVersionSizes[] = {{ 0, 40 }};
|
|
|
|
if (object->header_.version <=
|
|
kVersionSizes[arraysize(kVersionSizes) - 1].version) {
|
|
// Scan in reverse order to optimize for more recent versions.
|
|
for (int i = arraysize(kVersionSizes) - 1; i >= 0; --i) {
|
|
if (object->header_.version >= kVersionSizes[i].version) {
|
|
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
|
|
break;
|
|
|
|
ReportValidationError(
|
|
validation_context,
|
|
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
|
|
return false;
|
|
}
|
|
}
|
|
} else if (object->header_.num_bytes <
|
|
kVersionSizes[arraysize(kVersionSizes) - 1].num_bytes) {
|
|
ReportValidationError(
|
|
validation_context,
|
|
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
|
|
return false;
|
|
}
|
|
|
|
if (!mojo::internal::ValidatePointerNonNullable(
|
|
object->url, 2, validation_context)) {
|
|
return false;
|
|
}
|
|
if (!mojo::internal::ValidateStruct(object->url, validation_context))
|
|
return false;
|
|
|
|
if (!mojo::internal::ValidatePointerNonNullable(
|
|
object->origin, 3, validation_context)) {
|
|
return false;
|
|
}
|
|
if (!mojo::internal::ValidateStruct(object->origin, validation_context))
|
|
return false;
|
|
|
|
if (!mojo::internal::ValidatePointerNonNullable(
|
|
object->mime_type, 4, validation_context)) {
|
|
return false;
|
|
}
|
|
const mojo::internal::ContainerValidateParams mime_type_validate_params(
|
|
0, false, nullptr);
|
|
if (!mojo::internal::ValidateContainer(object->mime_type, validation_context,
|
|
&mime_type_validate_params)) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
PluginInfoHost_GetPluginInfo_Params_Data::PluginInfoHost_GetPluginInfo_Params_Data()
|
|
: header_({sizeof(*this), 0}) {}
|
|
|
|
|
|
// static
|
|
bool PluginInfoHost_GetPluginInfo_ResponseParams_Data::Validate(
|
|
const void* data,
|
|
mojo::internal::ValidationContext* validation_context) {
|
|
if (!data)
|
|
return true;
|
|
|
|
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
|
|
return false;
|
|
|
|
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
|
|
// the message comes from an older version.
|
|
const PluginInfoHost_GetPluginInfo_ResponseParams_Data* object = static_cast<const PluginInfoHost_GetPluginInfo_ResponseParams_Data*>(data);
|
|
|
|
static constexpr struct {
|
|
uint32_t version;
|
|
uint32_t num_bytes;
|
|
} kVersionSizes[] = {{ 0, 16 }};
|
|
|
|
if (object->header_.version <=
|
|
kVersionSizes[arraysize(kVersionSizes) - 1].version) {
|
|
// Scan in reverse order to optimize for more recent versions.
|
|
for (int i = arraysize(kVersionSizes) - 1; i >= 0; --i) {
|
|
if (object->header_.version >= kVersionSizes[i].version) {
|
|
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
|
|
break;
|
|
|
|
ReportValidationError(
|
|
validation_context,
|
|
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
|
|
return false;
|
|
}
|
|
}
|
|
} else if (object->header_.num_bytes <
|
|
kVersionSizes[arraysize(kVersionSizes) - 1].num_bytes) {
|
|
ReportValidationError(
|
|
validation_context,
|
|
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
|
|
return false;
|
|
}
|
|
|
|
if (!mojo::internal::ValidatePointerNonNullable(
|
|
object->plugin_info, 1, validation_context)) {
|
|
return false;
|
|
}
|
|
if (!mojo::internal::ValidateStruct(object->plugin_info, validation_context))
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
PluginInfoHost_GetPluginInfo_ResponseParams_Data::PluginInfoHost_GetPluginInfo_ResponseParams_Data()
|
|
: header_({sizeof(*this), 0}) {}
|
|
|
|
|
|
// static
|
|
bool PluginRenderer_FinishedDownloading_Params_Data::Validate(
|
|
const void* data,
|
|
mojo::internal::ValidationContext* validation_context) {
|
|
if (!data)
|
|
return true;
|
|
|
|
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
|
|
return false;
|
|
|
|
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
|
|
// the message comes from an older version.
|
|
const PluginRenderer_FinishedDownloading_Params_Data* object = static_cast<const PluginRenderer_FinishedDownloading_Params_Data*>(data);
|
|
|
|
static constexpr struct {
|
|
uint32_t version;
|
|
uint32_t num_bytes;
|
|
} kVersionSizes[] = {{ 0, 8 }};
|
|
|
|
if (object->header_.version <=
|
|
kVersionSizes[arraysize(kVersionSizes) - 1].version) {
|
|
// Scan in reverse order to optimize for more recent versions.
|
|
for (int i = arraysize(kVersionSizes) - 1; i >= 0; --i) {
|
|
if (object->header_.version >= kVersionSizes[i].version) {
|
|
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
|
|
break;
|
|
|
|
ReportValidationError(
|
|
validation_context,
|
|
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
|
|
return false;
|
|
}
|
|
}
|
|
} else if (object->header_.num_bytes <
|
|
kVersionSizes[arraysize(kVersionSizes) - 1].num_bytes) {
|
|
ReportValidationError(
|
|
validation_context,
|
|
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
PluginRenderer_FinishedDownloading_Params_Data::PluginRenderer_FinishedDownloading_Params_Data()
|
|
: header_({sizeof(*this), 0}) {}
|
|
|
|
|
|
// static
|
|
bool PluginRenderer_UpdateSuccess_Params_Data::Validate(
|
|
const void* data,
|
|
mojo::internal::ValidationContext* validation_context) {
|
|
if (!data)
|
|
return true;
|
|
|
|
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
|
|
return false;
|
|
|
|
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
|
|
// the message comes from an older version.
|
|
const PluginRenderer_UpdateSuccess_Params_Data* object = static_cast<const PluginRenderer_UpdateSuccess_Params_Data*>(data);
|
|
|
|
static constexpr struct {
|
|
uint32_t version;
|
|
uint32_t num_bytes;
|
|
} kVersionSizes[] = {{ 0, 8 }};
|
|
|
|
if (object->header_.version <=
|
|
kVersionSizes[arraysize(kVersionSizes) - 1].version) {
|
|
// Scan in reverse order to optimize for more recent versions.
|
|
for (int i = arraysize(kVersionSizes) - 1; i >= 0; --i) {
|
|
if (object->header_.version >= kVersionSizes[i].version) {
|
|
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
|
|
break;
|
|
|
|
ReportValidationError(
|
|
validation_context,
|
|
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
|
|
return false;
|
|
}
|
|
}
|
|
} else if (object->header_.num_bytes <
|
|
kVersionSizes[arraysize(kVersionSizes) - 1].num_bytes) {
|
|
ReportValidationError(
|
|
validation_context,
|
|
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
PluginRenderer_UpdateSuccess_Params_Data::PluginRenderer_UpdateSuccess_Params_Data()
|
|
: header_({sizeof(*this), 0}) {}
|
|
|
|
|
|
// static
|
|
bool PluginRenderer_UpdateFailure_Params_Data::Validate(
|
|
const void* data,
|
|
mojo::internal::ValidationContext* validation_context) {
|
|
if (!data)
|
|
return true;
|
|
|
|
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
|
|
return false;
|
|
|
|
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
|
|
// the message comes from an older version.
|
|
const PluginRenderer_UpdateFailure_Params_Data* object = static_cast<const PluginRenderer_UpdateFailure_Params_Data*>(data);
|
|
|
|
static constexpr struct {
|
|
uint32_t version;
|
|
uint32_t num_bytes;
|
|
} kVersionSizes[] = {{ 0, 8 }};
|
|
|
|
if (object->header_.version <=
|
|
kVersionSizes[arraysize(kVersionSizes) - 1].version) {
|
|
// Scan in reverse order to optimize for more recent versions.
|
|
for (int i = arraysize(kVersionSizes) - 1; i >= 0; --i) {
|
|
if (object->header_.version >= kVersionSizes[i].version) {
|
|
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
|
|
break;
|
|
|
|
ReportValidationError(
|
|
validation_context,
|
|
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
|
|
return false;
|
|
}
|
|
}
|
|
} else if (object->header_.num_bytes <
|
|
kVersionSizes[arraysize(kVersionSizes) - 1].num_bytes) {
|
|
ReportValidationError(
|
|
validation_context,
|
|
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
PluginRenderer_UpdateFailure_Params_Data::PluginRenderer_UpdateFailure_Params_Data()
|
|
: header_({sizeof(*this), 0}) {}
|
|
|
|
|
|
// static
|
|
bool PluginRenderer_UpdateDownloading_Params_Data::Validate(
|
|
const void* data,
|
|
mojo::internal::ValidationContext* validation_context) {
|
|
if (!data)
|
|
return true;
|
|
|
|
if (!ValidateStructHeaderAndClaimMemory(data, validation_context))
|
|
return false;
|
|
|
|
// NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
|
|
// the message comes from an older version.
|
|
const PluginRenderer_UpdateDownloading_Params_Data* object = static_cast<const PluginRenderer_UpdateDownloading_Params_Data*>(data);
|
|
|
|
static constexpr struct {
|
|
uint32_t version;
|
|
uint32_t num_bytes;
|
|
} kVersionSizes[] = {{ 0, 8 }};
|
|
|
|
if (object->header_.version <=
|
|
kVersionSizes[arraysize(kVersionSizes) - 1].version) {
|
|
// Scan in reverse order to optimize for more recent versions.
|
|
for (int i = arraysize(kVersionSizes) - 1; i >= 0; --i) {
|
|
if (object->header_.version >= kVersionSizes[i].version) {
|
|
if (object->header_.num_bytes == kVersionSizes[i].num_bytes)
|
|
break;
|
|
|
|
ReportValidationError(
|
|
validation_context,
|
|
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
|
|
return false;
|
|
}
|
|
}
|
|
} else if (object->header_.num_bytes <
|
|
kVersionSizes[arraysize(kVersionSizes) - 1].num_bytes) {
|
|
ReportValidationError(
|
|
validation_context,
|
|
mojo::internal::VALIDATION_ERROR_UNEXPECTED_STRUCT_HEADER);
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
PluginRenderer_UpdateDownloading_Params_Data::PluginRenderer_UpdateDownloading_Params_Data()
|
|
: header_({sizeof(*this), 0}) {}
|
|
|
|
} // namespace internal
|
|
} // namespace mojom
|
|
} // namespace chrome
|
|
|
|
#if defined(_MSC_VER)
|
|
#pragma warning(pop)
|
|
#endif
|