diff options
author | Thomas Van Lenten <thomasvl@google.com> | 2017-06-06 10:14:41 -0400 |
---|---|---|
committer | Thomas Van Lenten <thomasvl@google.com> | 2017-06-06 10:14:41 -0400 |
commit | ecc0f5412702e7f69b4578c92a120c56bdd79287 (patch) | |
tree | 874e512c4556a628f0204180b8d6e073bea67475 /objectivec/GPBCodedInputStream.m | |
parent | 656dedbf07ed88489bf60ddae4c583a0437d82cc (diff) | |
download | protobuf-ecc0f5412702e7f69b4578c92a120c56bdd79287.tar.gz protobuf-ecc0f5412702e7f69b4578c92a120c56bdd79287.tar.bz2 protobuf-ecc0f5412702e7f69b4578c92a120c56bdd79287.zip |
Properly error on a tag with field number zero.
Diffstat (limited to 'objectivec/GPBCodedInputStream.m')
-rw-r--r-- | objectivec/GPBCodedInputStream.m | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/objectivec/GPBCodedInputStream.m b/objectivec/GPBCodedInputStream.m index eef05353..22859e77 100644 --- a/objectivec/GPBCodedInputStream.m +++ b/objectivec/GPBCodedInputStream.m @@ -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; } |