From ecc0f5412702e7f69b4578c92a120c56bdd79287 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Tue, 6 Jun 2017 10:14:41 -0400 Subject: Properly error on a tag with field number zero. --- objectivec/GPBCodedInputStream.m | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'objectivec/GPBCodedInputStream.m') 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; } -- cgit v1.2.3