Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
00325ed9
Commit
00325ed9
authored
Sep 21, 2019
by
EFanZh
Committed by
Adam Cozzette
Sep 30, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update signatures of UTF-8 string functions to accept size_t type sizes
parent
a4301ca6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
64 additions
and
64 deletions
+64
-64
any.pb.cc
src/google/protobuf/any.pb.cc
+1
-1
api.pb.cc
src/google/protobuf/api.pb.cc
+7
-7
cpp_message.cc
src/google/protobuf/compiler/cpp/cpp_message.cc
+4
-4
plugin.pb.cc
src/google/protobuf/compiler/plugin.pb.cc
+7
-7
descriptor.pb.cc
src/google/protobuf/descriptor.pb.cc
+0
-0
field_mask.pb.cc
src/google/protobuf/field_mask.pb.cc
+1
-1
generated_message_table_driven_lite.h
src/google/protobuf/generated_message_table_driven_lite.h
+1
-1
source_context.pb.cc
src/google/protobuf/source_context.pb.cc
+1
-1
struct.pb.cc
src/google/protobuf/struct.pb.cc
+2
-2
common.h
src/google/protobuf/stubs/common.h
+3
-3
structurally_valid.cc
src/google/protobuf/stubs/structurally_valid.cc
+12
-12
structurally_valid_unittest.cc
src/google/protobuf/stubs/structurally_valid_unittest.cc
+2
-2
type.pb.cc
src/google/protobuf/type.pb.cc
+15
-15
json_stream_parser.cc
src/google/protobuf/util/internal/json_stream_parser.cc
+1
-1
wire_format.h
src/google/protobuf/wire_format.h
+4
-4
wire_format_lite.cc
src/google/protobuf/wire_format_lite.cc
+1
-1
wire_format_lite.h
src/google/protobuf/wire_format_lite.h
+1
-1
wrappers.pb.cc
src/google/protobuf/wrappers.pb.cc
+1
-1
No files found.
src/google/protobuf/any.pb.cc
View file @
00325ed9
...
...
@@ -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
(
...
...
src/google/protobuf/api.pb.cc
View file @
00325ed9
...
...
@@ -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
(
...
...
src/google/protobuf/compiler/cpp/cpp_message.cc
View file @
00325ed9
...
...
@@ -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(), s
tatic_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(), s
tatic_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(), s
tatic_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(), s
tatic_cast<int>(s->size()
), ::$proto_ns$::internal::"
" s->data(), s
->size(
), ::$proto_ns$::internal::"
"WireFormatLite::PARSE,
\"
$1$
\"
);
\n
"
"#endif
\n
"
" return true;
\n
"
...
...
src/google/protobuf/compiler/plugin.pb.cc
View file @
00325ed9
...
...
@@ -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
(),
s
tatic_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
(
...
...
src/google/protobuf/descriptor.pb.cc
View file @
00325ed9
This diff is collapsed.
Click to expand it.
src/google/protobuf/field_mask.pb.cc
View file @
00325ed9
...
...
@@ -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
(),
s
tatic_cast
<
int
>
(
s
.
length
()
),
s
.
data
(),
s
.
length
(
),
::
PROTOBUF_NAMESPACE_ID
::
internal
::
WireFormatLite
::
SERIALIZE
,
"google.protobuf.FieldMask.paths"
);
target
=
stream
->
WriteString
(
1
,
s
,
target
);
...
...
src/google/protobuf/generated_message_table_driven_lite.h
View file @
00325ed9
...
...
@@ -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
;
...
...
src/google/protobuf/source_context.pb.cc
View file @
00325ed9
...
...
@@ -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
(
...
...
src/google/protobuf/struct.pb.cc
View file @
00325ed9
...
...
@@ -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
(
...
...
src/google/protobuf/stubs/common.h
View file @
00325ed9
...
...
@@ -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
,
in
t
len
);
PROTOBUF_EXPORT
bool
IsStructurallyValidUTF8
(
const
char
*
buf
,
size_
t
len
);
inline
bool
IsStructurallyValidUTF8
(
const
std
::
string
&
str
)
{
return
IsStructurallyValidUTF8
(
str
.
data
(),
st
atic_cast
<
int
>
(
str
.
length
()
));
return
IsStructurallyValidUTF8
(
str
.
data
(),
st
r
.
length
(
));
}
// Returns initial number of bytes of structually valid UTF-8.
PROTOBUF_EXPORT
in
t
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
...
...
src/google/protobuf/stubs/structurally_valid.cc
View file @
00325ed9
...
...
@@ -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
,
in
t
str_length
,
in
t
*
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
,
in
t
str_length
,
in
t
*
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
;
in
t
n
;
in
t
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
,
in
t
len
)
{
bool
IsStructurallyValidUTF8
(
const
char
*
buf
,
size_
t
len
)
{
if
(
!
module_initialized_
)
return
true
;
in
t
bytes_consumed
=
0
;
size_
t
bytes_consumed
=
0
;
UTF8GenericScanFastAscii
(
&
utf8acceptnonsurrogates_obj
,
buf
,
len
,
&
bytes_consumed
);
return
(
bytes_consumed
==
len
);
}
in
t
UTF8SpnStructurallyValid
(
const
StringPiece
&
str
)
{
size_
t
UTF8SpnStructurallyValid
(
const
StringPiece
&
str
)
{
if
(
!
module_initialized_
)
return
str
.
size
();
in
t
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
in
t
len
=
src_str
.
length
();
in
t
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
...
...
src/google/protobuf/stubs/structurally_valid_unittest.cc
View file @
00325ed9
...
...
@@ -47,7 +47,7 @@ TEST(StructurallyValidTest, ValidUTF8String) {
EXPECT_TRUE
(
IsStructurallyValidUTF8
(
valid_str
.
data
(),
valid_str
.
size
()));
// Additional check for pointer alignment
for
(
in
t
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
(
in
t
i
=
1
;
i
<
8
;
++
i
)
{
for
(
size_
t
i
=
1
;
i
<
8
;
++
i
)
{
EXPECT_FALSE
(
IsStructurallyValidUTF8
(
invalid_str
.
data
()
+
i
,
invalid_str
.
size
()
-
i
));
}
...
...
src/google/protobuf/type.pb.cc
View file @
00325ed9
...
...
@@ -375,9 +375,9 @@ void Type::unsafe_arena_set_allocated_source_context(
}
source_context_
=
source_context
;
if
(
source_context
)
{
}
else
{
}
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Type.source_context)
}
...
...
@@ -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
(),
s
tatic_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
(
...
...
@@ -1262,9 +1262,9 @@ void Enum::unsafe_arena_set_allocated_source_context(
}
source_context_
=
source_context
;
if
(
source_context
)
{
}
else
{
}
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Enum.source_context)
}
...
...
@@ -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
(
...
...
@@ -1901,9 +1901,9 @@ void Option::unsafe_arena_set_allocated_value(
}
value_
=
value
;
if
(
value
)
{
}
else
{
}
// @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.Option.value)
}
...
...
@@ -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
(
...
...
src/google/protobuf/util/internal/json_stream_parser.cc
View file @
00325ed9
...
...
@@ -158,7 +158,7 @@ util::Status JsonStreamParser::Parse(StringPiece json) {
}
// Find the structurally valid UTF8 prefix and parse only that.
in
t
n
=
internal
::
UTF8SpnStructurallyValid
(
chunk
);
size_
t
n
=
internal
::
UTF8SpnStructurallyValid
(
chunk
);
if
(
n
>
0
)
{
util
::
Status
status
=
ParseChunk
(
chunk
.
substr
(
0
,
n
));
...
...
src/google/protobuf/wire_format.h
View file @
00325ed9
...
...
@@ -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
,
in
t
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
,
in
t
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
,
in
t
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
,
in
t
size
,
inline
void
WireFormat
::
VerifyUTF8StringNamedField
(
const
char
*
data
,
size_
t
size
,
WireFormat
::
Operation
op
,
const
char
*
field_name
)
{
#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
...
...
src/google/protobuf/wire_format_lite.cc
View file @
00325ed9
...
...
@@ -581,7 +581,7 @@ void PrintUTF8ErrorLog(const char* field_name, const char* operation_str,
<<
"bytes. "
<<
stacktrace
;
}
bool
WireFormatLite
::
VerifyUtf8String
(
const
char
*
data
,
in
t
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
;
...
...
src/google/protobuf/wire_format_lite.h
View file @
00325ed9
...
...
@@ -325,7 +325,7 @@ class PROTOBUF_EXPORT WireFormatLite {
};
// Returns true if the data is valid UTF-8.
static
bool
VerifyUtf8String
(
const
char
*
data
,
in
t
size
,
Operation
op
,
static
bool
VerifyUtf8String
(
const
char
*
data
,
size_
t
size
,
Operation
op
,
const
char
*
field_name
);
template
<
typename
MessageType
>
...
...
src/google/protobuf/wrappers.pb.cc
View file @
00325ed9
...
...
@@ -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
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment