Update signatures of UTF-8 string functions to accept size_t type sizes

pull/6612/head
EFanZh 5 years ago committed by Adam Cozzette
parent a4301ca6eb
commit 00325ed97b
  1. 2
      src/google/protobuf/any.pb.cc
  2. 14
      src/google/protobuf/api.pb.cc
  3. 8
      src/google/protobuf/compiler/cpp/cpp_message.cc
  4. 14
      src/google/protobuf/compiler/plugin.pb.cc
  5. 72
      src/google/protobuf/descriptor.pb.cc
  6. 2
      src/google/protobuf/field_mask.pb.cc
  7. 2
      src/google/protobuf/generated_message_table_driven_lite.h
  8. 2
      src/google/protobuf/source_context.pb.cc
  9. 4
      src/google/protobuf/struct.pb.cc
  10. 6
      src/google/protobuf/stubs/common.h
  11. 24
      src/google/protobuf/stubs/structurally_valid.cc
  12. 4
      src/google/protobuf/stubs/structurally_valid_unittest.cc
  13. 18
      src/google/protobuf/type.pb.cc
  14. 2
      src/google/protobuf/util/internal/json_stream_parser.cc
  15. 8
      src/google/protobuf/wire_format.h
  16. 2
      src/google/protobuf/wire_format_lite.cc
  17. 2
      src/google/protobuf/wire_format_lite.h
  18. 2
      src/google/protobuf/wrappers.pb.cc

@ -221,7 +221,7 @@ failure:
// string type_url = 1;
if (this->type_url().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_type_url().data(), static_cast<int>(this->_internal_type_url().length()),
this->_internal_type_url().data(), this->_internal_type_url().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"google.protobuf.Any.type_url");
target = stream->WriteStringMaybeAliased(

@ -373,7 +373,7 @@ failure:
// string name = 1;
if (this->name().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
this->_internal_name().data(), this->_internal_name().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"google.protobuf.Api.name");
target = stream->WriteStringMaybeAliased(
@ -399,7 +399,7 @@ failure:
// string version = 4;
if (this->version().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_version().data(), static_cast<int>(this->_internal_version().length()),
this->_internal_version().data(), this->_internal_version().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"google.protobuf.Api.version");
target = stream->WriteStringMaybeAliased(
@ -756,7 +756,7 @@ failure:
// string name = 1;
if (this->name().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
this->_internal_name().data(), this->_internal_name().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"google.protobuf.Method.name");
target = stream->WriteStringMaybeAliased(
@ -766,7 +766,7 @@ failure:
// string request_type_url = 2;
if (this->request_type_url().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_request_type_url().data(), static_cast<int>(this->_internal_request_type_url().length()),
this->_internal_request_type_url().data(), this->_internal_request_type_url().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"google.protobuf.Method.request_type_url");
target = stream->WriteStringMaybeAliased(
@ -782,7 +782,7 @@ failure:
// string response_type_url = 4;
if (this->response_type_url().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_response_type_url().data(), static_cast<int>(this->_internal_response_type_url().length()),
this->_internal_response_type_url().data(), this->_internal_response_type_url().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"google.protobuf.Method.response_type_url");
target = stream->WriteStringMaybeAliased(
@ -1077,7 +1077,7 @@ failure:
// string name = 1;
if (this->name().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
this->_internal_name().data(), this->_internal_name().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"google.protobuf.Mixin.name");
target = stream->WriteStringMaybeAliased(
@ -1087,7 +1087,7 @@ failure:
// string root = 2;
if (this->root().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_root().data(), static_cast<int>(this->_internal_root().length()),
this->_internal_root().data(), this->_internal_root().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"google.protobuf.Mixin.root");
target = stream->WriteStringMaybeAliased(

@ -1030,7 +1030,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
format(
" static bool ValidateKey(std::string* s) {\n"
" return ::$proto_ns$::internal::WireFormatLite::"
"VerifyUtf8String(s->data(), static_cast<int>(s->size()), "
"VerifyUtf8String(s->data(), s->size(), "
"::$proto_ns$::internal::WireFormatLite::PARSE, \"$1$\");\n"
" }\n",
descriptor_->field(0)->full_name());
@ -1040,7 +1040,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
" static bool ValidateKey(std::string* s) {\n"
"#ifndef NDEBUG\n"
" ::$proto_ns$::internal::WireFormatLite::VerifyUtf8String(\n"
" s->data(), static_cast<int>(s->size()), ::$proto_ns$::internal::"
" s->data(), s->size(), ::$proto_ns$::internal::"
"WireFormatLite::PARSE, \"$1$\");\n"
"#endif\n"
" return true;\n"
@ -1056,7 +1056,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
format(
" static bool ValidateValue(std::string* s) {\n"
" return ::$proto_ns$::internal::WireFormatLite::"
"VerifyUtf8String(s->data(), static_cast<int>(s->size()), "
"VerifyUtf8String(s->data(), s->size(), "
"::$proto_ns$::internal::WireFormatLite::PARSE, \"$1$\");\n"
" }\n",
descriptor_->field(1)->full_name());
@ -1066,7 +1066,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
" static bool ValidateValue(std::string* s) {\n"
"#ifndef NDEBUG\n"
" ::$proto_ns$::internal::WireFormatLite::VerifyUtf8String(\n"
" s->data(), static_cast<int>(s->size()), ::$proto_ns$::internal::"
" s->data(), s->size(), ::$proto_ns$::internal::"
"WireFormatLite::PARSE, \"$1$\");\n"
"#endif\n"
" return true;\n"

@ -377,7 +377,7 @@ failure:
// optional string suffix = 4;
if (cached_has_bits & 0x00000001u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_suffix().data(), static_cast<int>(this->_internal_suffix().length()),
this->_internal_suffix().data(), this->_internal_suffix().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.compiler.Version.suffix");
target = stream->WriteStringMaybeAliased(
@ -688,7 +688,7 @@ failure:
for (int i = 0, n = this->_internal_file_to_generate_size(); i < n; i++) {
const auto& s = this->_internal_file_to_generate(i);
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
s.data(), static_cast<int>(s.length()),
s.data(), s.length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.compiler.CodeGeneratorRequest.file_to_generate");
target = stream->WriteString(1, s, target);
@ -698,7 +698,7 @@ failure:
// optional string parameter = 2;
if (cached_has_bits & 0x00000001u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_parameter().data(), static_cast<int>(this->_internal_parameter().length()),
this->_internal_parameter().data(), this->_internal_parameter().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.compiler.CodeGeneratorRequest.parameter");
target = stream->WriteStringMaybeAliased(
@ -1001,7 +1001,7 @@ failure:
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
this->_internal_name().data(), this->_internal_name().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.compiler.CodeGeneratorResponse.File.name");
target = stream->WriteStringMaybeAliased(
@ -1011,7 +1011,7 @@ failure:
// optional string insertion_point = 2;
if (cached_has_bits & 0x00000002u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_insertion_point().data(), static_cast<int>(this->_internal_insertion_point().length()),
this->_internal_insertion_point().data(), this->_internal_insertion_point().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point");
target = stream->WriteStringMaybeAliased(
@ -1021,7 +1021,7 @@ failure:
// optional string content = 15;
if (cached_has_bits & 0x00000004u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_content().data(), static_cast<int>(this->_internal_content().length()),
this->_internal_content().data(), this->_internal_content().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.compiler.CodeGeneratorResponse.File.content");
target = stream->WriteStringMaybeAliased(
@ -1277,7 +1277,7 @@ failure:
// optional string error = 1;
if (cached_has_bits & 0x00000001u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_error().data(), static_cast<int>(this->_internal_error().length()),
this->_internal_error().data(), this->_internal_error().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.compiler.CodeGeneratorResponse.error");
target = stream->WriteStringMaybeAliased(

@ -1952,7 +1952,7 @@ failure:
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
this->_internal_name().data(), this->_internal_name().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.FileDescriptorProto.name");
target = stream->WriteStringMaybeAliased(
@ -1962,7 +1962,7 @@ failure:
// optional string package = 2;
if (cached_has_bits & 0x00000002u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_package().data(), static_cast<int>(this->_internal_package().length()),
this->_internal_package().data(), this->_internal_package().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.FileDescriptorProto.package");
target = stream->WriteStringMaybeAliased(
@ -1973,7 +1973,7 @@ failure:
for (int i = 0, n = this->_internal_dependency_size(); i < n; i++) {
const auto& s = this->_internal_dependency(i);
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
s.data(), static_cast<int>(s.length()),
s.data(), s.length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.FileDescriptorProto.dependency");
target = stream->WriteString(3, s, target);
@ -2042,7 +2042,7 @@ failure:
// optional string syntax = 12;
if (cached_has_bits & 0x00000004u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_syntax().data(), static_cast<int>(this->_internal_syntax().length()),
this->_internal_syntax().data(), this->_internal_syntax().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.FileDescriptorProto.syntax");
target = stream->WriteStringMaybeAliased(
@ -3132,7 +3132,7 @@ failure:
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
this->_internal_name().data(), this->_internal_name().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.DescriptorProto.name");
target = stream->WriteStringMaybeAliased(
@ -3207,7 +3207,7 @@ failure:
for (int i = 0, n = this->_internal_reserved_name_size(); i < n; i++) {
const auto& s = this->_internal_reserved_name(i);
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
s.data(), static_cast<int>(s.length()),
s.data(), s.length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.DescriptorProto.reserved_name");
target = stream->WriteString(10, s, target);
@ -3954,7 +3954,7 @@ failure:
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
this->_internal_name().data(), this->_internal_name().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.FieldDescriptorProto.name");
target = stream->WriteStringMaybeAliased(
@ -3964,7 +3964,7 @@ failure:
// optional string extendee = 2;
if (cached_has_bits & 0x00000002u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_extendee().data(), static_cast<int>(this->_internal_extendee().length()),
this->_internal_extendee().data(), this->_internal_extendee().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.FieldDescriptorProto.extendee");
target = stream->WriteStringMaybeAliased(
@ -3994,7 +3994,7 @@ failure:
// optional string type_name = 6;
if (cached_has_bits & 0x00000004u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_type_name().data(), static_cast<int>(this->_internal_type_name().length()),
this->_internal_type_name().data(), this->_internal_type_name().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.FieldDescriptorProto.type_name");
target = stream->WriteStringMaybeAliased(
@ -4004,7 +4004,7 @@ failure:
// optional string default_value = 7;
if (cached_has_bits & 0x00000008u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_default_value().data(), static_cast<int>(this->_internal_default_value().length()),
this->_internal_default_value().data(), this->_internal_default_value().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.FieldDescriptorProto.default_value");
target = stream->WriteStringMaybeAliased(
@ -4028,7 +4028,7 @@ failure:
// optional string json_name = 10;
if (cached_has_bits & 0x00000010u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_json_name().data(), static_cast<int>(this->_internal_json_name().length()),
this->_internal_json_name().data(), this->_internal_json_name().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.FieldDescriptorProto.json_name");
target = stream->WriteStringMaybeAliased(
@ -4412,7 +4412,7 @@ failure:
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
this->_internal_name().data(), this->_internal_name().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.OneofDescriptorProto.name");
target = stream->WriteStringMaybeAliased(
@ -5009,7 +5009,7 @@ failure:
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
this->_internal_name().data(), this->_internal_name().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.EnumDescriptorProto.name");
target = stream->WriteStringMaybeAliased(
@ -5044,7 +5044,7 @@ failure:
for (int i = 0, n = this->_internal_reserved_name_size(); i < n; i++) {
const auto& s = this->_internal_reserved_name(i);
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
s.data(), static_cast<int>(s.length()),
s.data(), s.length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.EnumDescriptorProto.reserved_name");
target = stream->WriteString(5, s, target);
@ -5375,7 +5375,7 @@ failure:
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
this->_internal_name().data(), this->_internal_name().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.EnumValueDescriptorProto.name");
target = stream->WriteStringMaybeAliased(
@ -5704,7 +5704,7 @@ failure:
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
this->_internal_name().data(), this->_internal_name().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.ServiceDescriptorProto.name");
target = stream->WriteStringMaybeAliased(
@ -6088,7 +6088,7 @@ failure:
// optional string name = 1;
if (cached_has_bits & 0x00000001u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
this->_internal_name().data(), this->_internal_name().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.MethodDescriptorProto.name");
target = stream->WriteStringMaybeAliased(
@ -6098,7 +6098,7 @@ failure:
// optional string input_type = 2;
if (cached_has_bits & 0x00000002u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_input_type().data(), static_cast<int>(this->_internal_input_type().length()),
this->_internal_input_type().data(), this->_internal_input_type().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.MethodDescriptorProto.input_type");
target = stream->WriteStringMaybeAliased(
@ -6108,7 +6108,7 @@ failure:
// optional string output_type = 3;
if (cached_has_bits & 0x00000004u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_output_type().data(), static_cast<int>(this->_internal_output_type().length()),
this->_internal_output_type().data(), this->_internal_output_type().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.MethodDescriptorProto.output_type");
target = stream->WriteStringMaybeAliased(
@ -6756,7 +6756,7 @@ failure:
// optional string java_package = 1;
if (cached_has_bits & 0x00000001u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_java_package().data(), static_cast<int>(this->_internal_java_package().length()),
this->_internal_java_package().data(), this->_internal_java_package().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.FileOptions.java_package");
target = stream->WriteStringMaybeAliased(
@ -6766,7 +6766,7 @@ failure:
// optional string java_outer_classname = 8;
if (cached_has_bits & 0x00000002u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_java_outer_classname().data(), static_cast<int>(this->_internal_java_outer_classname().length()),
this->_internal_java_outer_classname().data(), this->_internal_java_outer_classname().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.FileOptions.java_outer_classname");
target = stream->WriteStringMaybeAliased(
@ -6789,7 +6789,7 @@ failure:
// optional string go_package = 11;
if (cached_has_bits & 0x00000004u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_go_package().data(), static_cast<int>(this->_internal_go_package().length()),
this->_internal_go_package().data(), this->_internal_go_package().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.FileOptions.go_package");
target = stream->WriteStringMaybeAliased(
@ -6841,7 +6841,7 @@ failure:
// optional string objc_class_prefix = 36;
if (cached_has_bits & 0x00000008u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_objc_class_prefix().data(), static_cast<int>(this->_internal_objc_class_prefix().length()),
this->_internal_objc_class_prefix().data(), this->_internal_objc_class_prefix().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.FileOptions.objc_class_prefix");
target = stream->WriteStringMaybeAliased(
@ -6851,7 +6851,7 @@ failure:
// optional string csharp_namespace = 37;
if (cached_has_bits & 0x00000010u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_csharp_namespace().data(), static_cast<int>(this->_internal_csharp_namespace().length()),
this->_internal_csharp_namespace().data(), this->_internal_csharp_namespace().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.FileOptions.csharp_namespace");
target = stream->WriteStringMaybeAliased(
@ -6861,7 +6861,7 @@ failure:
// optional string swift_prefix = 39;
if (cached_has_bits & 0x00000020u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_swift_prefix().data(), static_cast<int>(this->_internal_swift_prefix().length()),
this->_internal_swift_prefix().data(), this->_internal_swift_prefix().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.FileOptions.swift_prefix");
target = stream->WriteStringMaybeAliased(
@ -6871,7 +6871,7 @@ failure:
// optional string php_class_prefix = 40;
if (cached_has_bits & 0x00000040u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_php_class_prefix().data(), static_cast<int>(this->_internal_php_class_prefix().length()),
this->_internal_php_class_prefix().data(), this->_internal_php_class_prefix().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.FileOptions.php_class_prefix");
target = stream->WriteStringMaybeAliased(
@ -6881,7 +6881,7 @@ failure:
// optional string php_namespace = 41;
if (cached_has_bits & 0x00000080u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_php_namespace().data(), static_cast<int>(this->_internal_php_namespace().length()),
this->_internal_php_namespace().data(), this->_internal_php_namespace().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.FileOptions.php_namespace");
target = stream->WriteStringMaybeAliased(
@ -6897,7 +6897,7 @@ failure:
// optional string php_metadata_namespace = 44;
if (cached_has_bits & 0x00000100u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_php_metadata_namespace().data(), static_cast<int>(this->_internal_php_metadata_namespace().length()),
this->_internal_php_metadata_namespace().data(), this->_internal_php_metadata_namespace().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.FileOptions.php_metadata_namespace");
target = stream->WriteStringMaybeAliased(
@ -6907,7 +6907,7 @@ failure:
// optional string ruby_package = 45;
if (cached_has_bits & 0x00000200u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_ruby_package().data(), static_cast<int>(this->_internal_ruby_package().length()),
this->_internal_ruby_package().data(), this->_internal_ruby_package().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.FileOptions.ruby_package");
target = stream->WriteStringMaybeAliased(
@ -9552,7 +9552,7 @@ failure:
// required string name_part = 1;
if (cached_has_bits & 0x00000001u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_name_part().data(), static_cast<int>(this->_internal_name_part().length()),
this->_internal_name_part().data(), this->_internal_name_part().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.UninterpretedOption.NamePart.name_part");
target = stream->WriteStringMaybeAliased(
@ -9924,7 +9924,7 @@ failure:
// optional string identifier_value = 3;
if (cached_has_bits & 0x00000001u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_identifier_value().data(), static_cast<int>(this->_internal_identifier_value().length()),
this->_internal_identifier_value().data(), this->_internal_identifier_value().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.UninterpretedOption.identifier_value");
target = stream->WriteStringMaybeAliased(
@ -9958,7 +9958,7 @@ failure:
// optional string aggregate_value = 8;
if (cached_has_bits & 0x00000004u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_aggregate_value().data(), static_cast<int>(this->_internal_aggregate_value().length()),
this->_internal_aggregate_value().data(), this->_internal_aggregate_value().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.UninterpretedOption.aggregate_value");
target = stream->WriteStringMaybeAliased(
@ -10336,7 +10336,7 @@ failure:
// optional string leading_comments = 3;
if (cached_has_bits & 0x00000001u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_leading_comments().data(), static_cast<int>(this->_internal_leading_comments().length()),
this->_internal_leading_comments().data(), this->_internal_leading_comments().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.SourceCodeInfo.Location.leading_comments");
target = stream->WriteStringMaybeAliased(
@ -10346,7 +10346,7 @@ failure:
// optional string trailing_comments = 4;
if (cached_has_bits & 0x00000002u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_trailing_comments().data(), static_cast<int>(this->_internal_trailing_comments().length()),
this->_internal_trailing_comments().data(), this->_internal_trailing_comments().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.SourceCodeInfo.Location.trailing_comments");
target = stream->WriteStringMaybeAliased(
@ -10357,7 +10357,7 @@ failure:
for (int i = 0, n = this->_internal_leading_detached_comments_size(); i < n; i++) {
const auto& s = this->_internal_leading_detached_comments(i);
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
s.data(), static_cast<int>(s.length()),
s.data(), s.length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.SourceCodeInfo.Location.leading_detached_comments");
target = stream->WriteString(6, s, target);
@ -10909,7 +10909,7 @@ failure:
// optional string source_file = 2;
if (cached_has_bits & 0x00000001u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_source_file().data(), static_cast<int>(this->_internal_source_file().length()),
this->_internal_source_file().data(), this->_internal_source_file().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
"google.protobuf.GeneratedCodeInfo.Annotation.source_file");
target = stream->WriteStringMaybeAliased(

@ -197,7 +197,7 @@ failure:
for (int i = 0, n = this->_internal_paths_size(); i < n; i++) {
const auto& s = this->_internal_paths(i);
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
s.data(), static_cast<int>(s.length()),
s.data(), s.length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"google.protobuf.FieldMask.paths");
target = stream->WriteString(1, s, target);

@ -298,7 +298,7 @@ static inline bool HandleString(io::CodedInputStream* input, MessageLite* msg,
if (kValidateUtf8) {
// TODO(b/118759213): fail if proto3
WireFormatLite::VerifyUtf8String(utf8_string_data.data(),
utf8_string_data.length(),
static_cast<size_t>(utf8_string_data.length()),
WireFormatLite::PARSE, field_name);
}
return true;

@ -181,7 +181,7 @@ failure:
// string file_name = 1;
if (this->file_name().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_file_name().data(), static_cast<int>(this->_internal_file_name().length()),
this->_internal_file_name().data(), this->_internal_file_name().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"google.protobuf.SourceContext.file_name");
target = stream->WriteStringMaybeAliased(

@ -312,7 +312,7 @@ failure:
struct Utf8Check {
static void Check(ConstPtr p) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
p->first.data(), static_cast<int>(p->first.length()),
p->first.data(), p->first.length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"google.protobuf.Struct.FieldsEntry.key");
}
@ -713,7 +713,7 @@ failure:
// string string_value = 3;
if (_internal_has_string_value()) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_string_value().data(), static_cast<int>(this->_internal_string_value().length()),
this->_internal_string_value().data(), this->_internal_string_value().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"google.protobuf.Value.string_value");
target = stream->WriteStringMaybeAliased(

@ -127,14 +127,14 @@ namespace internal {
// Checks if the buffer contains structurally-valid UTF-8. Implemented in
// structurally_valid.cc.
PROTOBUF_EXPORT bool IsStructurallyValidUTF8(const char* buf, int len);
PROTOBUF_EXPORT bool IsStructurallyValidUTF8(const char* buf, size_t len);
inline bool IsStructurallyValidUTF8(const std::string& str) {
return IsStructurallyValidUTF8(str.data(), static_cast<int>(str.length()));
return IsStructurallyValidUTF8(str.data(), str.length());
}
// Returns initial number of bytes of structually valid UTF-8.
PROTOBUF_EXPORT int UTF8SpnStructurallyValid(const StringPiece& str);
PROTOBUF_EXPORT size_t UTF8SpnStructurallyValid(const StringPiece& str);
// Coerce UTF-8 byte string in src_str to be
// a structurally-valid equal-length string by selectively

@ -386,8 +386,8 @@ static inline bool InStateZero(const UTF8ScanObj* st, const uint8* Tbl) {
// Set number of bytes scanned. Return reason for exiting
int UTF8GenericScan(const UTF8ScanObj* st,
const char * str,
int str_length,
int* bytes_consumed) {
size_t str_length,
size_t* bytes_consumed) {
*bytes_consumed = 0;
if (str_length == 0) return kExitOK;
@ -496,8 +496,8 @@ int UTF8GenericScan(const UTF8ScanObj* st,
int UTF8GenericScanFastAscii(const UTF8ScanObj* st,
const char * str,
int str_length,
int* bytes_consumed) {
size_t str_length,
size_t* bytes_consumed) {
*bytes_consumed = 0;
if (str_length == 0) return kExitOK;
@ -505,8 +505,8 @@ int UTF8GenericScanFastAscii(const UTF8ScanObj* st,
const uint8* src = isrc;
const uint8* srclimit = isrc + str_length;
const uint8* srclimit8 = srclimit - 7;
int n;
int rest_consumed;
size_t n;
size_t rest_consumed;
int exit_reason;
do {
// Check initial few bytes one at a time until 8-byte aligned
@ -553,19 +553,19 @@ InitDetector init_detector;
} // namespace
bool IsStructurallyValidUTF8(const char* buf, int len) {
bool IsStructurallyValidUTF8(const char* buf, size_t len) {
if (!module_initialized_) return true;
int bytes_consumed = 0;
size_t bytes_consumed = 0;
UTF8GenericScanFastAscii(&utf8acceptnonsurrogates_obj,
buf, len, &bytes_consumed);
return (bytes_consumed == len);
}
int UTF8SpnStructurallyValid(const StringPiece& str) {
size_t UTF8SpnStructurallyValid(const StringPiece& str) {
if (!module_initialized_) return str.size();
int bytes_consumed = 0;
size_t bytes_consumed = 0;
UTF8GenericScanFastAscii(&utf8acceptnonsurrogates_obj,
str.data(), str.size(), &bytes_consumed);
return bytes_consumed;
@ -587,8 +587,8 @@ char* UTF8CoerceToStructurallyValid(const StringPiece& src_str,
char* idst,
const char replace_char) {
const char* isrc = src_str.data();
const int len = src_str.length();
int n = UTF8SpnStructurallyValid(src_str);
const size_t len = src_str.length();
size_t n = UTF8SpnStructurallyValid(src_str);
if (n == len) { // Normal case -- all is cool, return
return const_cast<char*>(isrc);
} else { // Unusual case -- copy w/o bad bytes

@ -47,7 +47,7 @@ TEST(StructurallyValidTest, ValidUTF8String) {
EXPECT_TRUE(IsStructurallyValidUTF8(valid_str.data(),
valid_str.size()));
// Additional check for pointer alignment
for (int i = 1; i < 8; ++i) {
for (size_t i = 1; i < 8; ++i) {
EXPECT_TRUE(IsStructurallyValidUTF8(valid_str.data() + i,
valid_str.size() - i));
}
@ -58,7 +58,7 @@ TEST(StructurallyValidTest, InvalidUTF8String) {
EXPECT_FALSE(IsStructurallyValidUTF8(invalid_str.data(),
invalid_str.size()));
// Additional check for pointer alignment
for (int i = 1; i < 8; ++i) {
for (size_t i = 1; i < 8; ++i) {
EXPECT_FALSE(IsStructurallyValidUTF8(invalid_str.data() + i,
invalid_str.size() - i));
}

@ -570,7 +570,7 @@ failure:
// string name = 1;
if (this->name().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
this->_internal_name().data(), this->_internal_name().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"google.protobuf.Type.name");
target = stream->WriteStringMaybeAliased(
@ -589,7 +589,7 @@ failure:
for (int i = 0, n = this->_internal_oneofs_size(); i < n; i++) {
const auto& s = this->_internal_oneofs(i);
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
s.data(), static_cast<int>(s.length()),
s.data(), s.length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"google.protobuf.Type.oneofs");
target = stream->WriteString(3, s, target);
@ -998,7 +998,7 @@ failure:
// string name = 4;
if (this->name().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
this->_internal_name().data(), this->_internal_name().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"google.protobuf.Field.name");
target = stream->WriteStringMaybeAliased(
@ -1008,7 +1008,7 @@ failure:
// string type_url = 6;
if (this->type_url().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_type_url().data(), static_cast<int>(this->_internal_type_url().length()),
this->_internal_type_url().data(), this->_internal_type_url().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"google.protobuf.Field.type_url");
target = stream->WriteStringMaybeAliased(
@ -1038,7 +1038,7 @@ failure:
// string json_name = 10;
if (this->json_name().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_json_name().data(), static_cast<int>(this->_internal_json_name().length()),
this->_internal_json_name().data(), this->_internal_json_name().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"google.protobuf.Field.json_name");
target = stream->WriteStringMaybeAliased(
@ -1048,7 +1048,7 @@ failure:
// string default_value = 11;
if (this->default_value().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_default_value().data(), static_cast<int>(this->_internal_default_value().length()),
this->_internal_default_value().data(), this->_internal_default_value().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"google.protobuf.Field.default_value");
target = stream->WriteStringMaybeAliased(
@ -1442,7 +1442,7 @@ failure:
// string name = 1;
if (this->name().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
this->_internal_name().data(), this->_internal_name().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"google.protobuf.Enum.name");
target = stream->WriteStringMaybeAliased(
@ -1749,7 +1749,7 @@ failure:
// string name = 1;
if (this->name().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
this->_internal_name().data(), this->_internal_name().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"google.protobuf.EnumValue.name");
target = stream->WriteStringMaybeAliased(
@ -2039,7 +2039,7 @@ failure:
// string name = 1;
if (this->name().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
this->_internal_name().data(), this->_internal_name().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"google.protobuf.Option.name");
target = stream->WriteStringMaybeAliased(

@ -158,7 +158,7 @@ util::Status JsonStreamParser::Parse(StringPiece json) {
}
// Find the structurally valid UTF8 prefix and parse only that.
int n = internal::UTF8SpnStructurallyValid(chunk);
size_t n = internal::UTF8SpnStructurallyValid(chunk);
if (n > 0) {
util::Status status = ParseChunk(chunk.substr(0, n));

@ -268,10 +268,10 @@ class PROTOBUF_EXPORT WireFormat {
// Verifies that a string field is valid UTF8, logging an error if not.
// This function will not be called by newly generated protobuf code
// but remains present to support existing code.
static void VerifyUTF8String(const char* data, int size, Operation op);
static void VerifyUTF8String(const char* data, size_t size, Operation op);
// The NamedField variant takes a field name in order to produce an
// informative error message if verification fails.
static void VerifyUTF8StringNamedField(const char* data, int size,
static void VerifyUTF8StringNamedField(const char* data, size_t size,
Operation op, const char* field_name);
private:
@ -337,7 +337,7 @@ inline size_t WireFormat::TagSize(int field_number,
static_cast<WireFormatLite::FieldType>(implicit_cast<int>(type)));
}
inline void WireFormat::VerifyUTF8String(const char* data, int size,
inline void WireFormat::VerifyUTF8String(const char* data, size_t size,
WireFormat::Operation op) {
#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
WireFormatLite::VerifyUtf8String(
@ -350,7 +350,7 @@ inline void WireFormat::VerifyUTF8String(const char* data, int size,
#endif
}
inline void WireFormat::VerifyUTF8StringNamedField(const char* data, int size,
inline void WireFormat::VerifyUTF8StringNamedField(const char* data, size_t size,
WireFormat::Operation op,
const char* field_name) {
#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED

@ -581,7 +581,7 @@ void PrintUTF8ErrorLog(const char* field_name, const char* operation_str,
<< "bytes. " << stacktrace;
}
bool WireFormatLite::VerifyUtf8String(const char* data, int size, Operation op,
bool WireFormatLite::VerifyUtf8String(const char* data, size_t size, Operation op,
const char* field_name) {
if (!IsStructurallyValidUTF8(data, size)) {
const char* operation_str = NULL;

@ -325,7 +325,7 @@ class PROTOBUF_EXPORT WireFormatLite {
};
// Returns true if the data is valid UTF-8.
static bool VerifyUtf8String(const char* data, int size, Operation op,
static bool VerifyUtf8String(const char* data, size_t size, Operation op,
const char* field_name);
template <typename MessageType>

@ -1819,7 +1819,7 @@ failure:
// string value = 1;
if (this->value().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_value().data(), static_cast<int>(this->_internal_value().length()),
this->_internal_value().data(), this->_internal_value().length(),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"google.protobuf.StringValue.value");
target = stream->WriteStringMaybeAliased(

Loading…
Cancel
Save