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
ecc0f541
Commit
ecc0f541
authored
Jun 06, 2017
by
Thomas Van Lenten
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly error on a tag with field number zero.
parent
656dedbf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
10 deletions
+41
-10
failure_list_objc.txt
conformance/failure_list_objc.txt
+0
-4
GPBCodedInputStream.m
objectivec/GPBCodedInputStream.m
+6
-6
GPBMessageTests+Serialization.m
objectivec/Tests/GPBMessageTests+Serialization.m
+35
-0
No files found.
conformance/failure_list_objc.txt
View file @
ecc0f541
# JSON input or output tests are skipped (in conformance_objc.m) as mobile
# platforms don't support JSON wire format to avoid code bloat.
Required.ProtobufInput.IllegalZeroFieldNum_Case_0
Required.ProtobufInput.IllegalZeroFieldNum_Case_1
Required.ProtobufInput.IllegalZeroFieldNum_Case_2
Required.ProtobufInput.IllegalZeroFieldNum_Case_3
objectivec/GPBCodedInputStream.m
View file @
ecc0f541
...
...
@@ -230,16 +230,16 @@ int32_t GPBCodedInputStreamReadTag(GPBCodedInputStreamState *state) {
}
state
->
lastTag
=
ReadRawVarint32
(
state
);
if
(
state
->
lastTag
==
0
)
{
// If we actually read zero, that's not a valid tag.
RaiseException
(
GPBCodedInputStreamErrorInvalidTag
,
@"A zero tag on the wire is invalid."
);
}
// Tags have to include a valid wireformat, check that also.
// Tags have to include a valid wireformat.
if
(
!
GPBWireFormatIsValidTag
(
state
->
lastTag
))
{
RaiseException
(
GPBCodedInputStreamErrorInvalidTag
,
@"Invalid wireformat in tag."
);
}
// Zero is not a valid field number.
if
(
GPBWireFormatGetTagFieldNumber
(
state
->
lastTag
)
==
0
)
{
RaiseException
(
GPBCodedInputStreamErrorInvalidTag
,
@"A zero field number on the wire is invalid."
);
}
return
state
->
lastTag
;
}
...
...
objectivec/Tests/GPBMessageTests+Serialization.m
View file @
ecc0f541
...
...
@@ -946,6 +946,41 @@ static NSData *DataFromCStr(const char *str) {
XCTAssertEqual
(
error
.
code
,
GPBCodedInputStreamErrorInvalidTag
);
}
-
(
void
)
testZeroFieldNum
{
// These are ConformanceTestSuite::TestIllegalTags.
const
char
*
tests
[]
=
{
"
\1
DEADBEEF"
,
"
\2\1\1
"
,
"
\3\4
"
,
"
\5
DEAD"
};
for
(
size_t
i
=
0
;
i
<
GPBARRAYSIZE
(
tests
);
++
i
)
{
NSData
*
data
=
DataFromCStr
(
tests
[
i
]);
{
// Message from proto2 syntax file
NSError
*
error
=
nil
;
Message2
*
msg
=
[
Message2
parseFromData
:
data
error
:
&
error
];
XCTAssertNil
(
msg
,
@"i = %zd"
,
i
);
XCTAssertNotNil
(
error
,
@"i = %zd"
,
i
);
XCTAssertEqualObjects
(
error
.
domain
,
GPBCodedInputStreamErrorDomain
,
@"i = %zd"
,
i
);
XCTAssertEqual
(
error
.
code
,
GPBCodedInputStreamErrorInvalidTag
,
@"i = %zd"
,
i
);
}
{
// Message from proto3 syntax file
NSError
*
error
=
nil
;
Message3
*
msg
=
[
Message3
parseFromData
:
data
error
:
&
error
];
XCTAssertNil
(
msg
,
@"i = %zd"
,
i
);
XCTAssertNotNil
(
error
,
@"i = %zd"
,
i
);
XCTAssertEqualObjects
(
error
.
domain
,
GPBCodedInputStreamErrorDomain
,
@"i = %zd"
,
i
);
XCTAssertEqual
(
error
.
code
,
GPBCodedInputStreamErrorInvalidTag
,
@"i = %zd"
,
i
);
}
}
}
-
(
void
)
testErrorRecursionDepthReached
{
NSData
*
data
=
DataFromCStr
(
"
\x0A\xF2\x01\x0A\xEF\x01\x0A\xEC\x01\x0A\xE9\x01\x0A\xE6\x01
"
...
...
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