aboutsummaryrefslogtreecommitdiff
path: root/objectivec/GPBWireFormat.h
diff options
context:
space:
mode:
authorThomas Van Lenten <thomasvl@google.com>2016-06-29 09:51:13 -0400
committerGitHub <noreply@github.com>2016-06-29 09:51:13 -0400
commitc18aa7795a2e02ef700ff8b039d94ecdcc33432f (patch)
tree6a1c28a6dbfd0ef412c23236d1aa8d4f2c76abe5 /objectivec/GPBWireFormat.h
parente0016c5b6ae61ad60d260a78c5834cc537b46d10 (diff)
downloadprotobuf-c18aa7795a2e02ef700ff8b039d94ecdcc33432f.tar.gz
protobuf-c18aa7795a2e02ef700ff8b039d94ecdcc33432f.tar.bz2
protobuf-c18aa7795a2e02ef700ff8b039d94ecdcc33432f.zip
Validate the tag numbers when parsing. (#1725)
There was a twist code path (that some times showed up due to what happened to be in memory in failure cases), that would cast a bogus wire type into the enum, and then fall through switch statements. Resolve this by validating all wire types when parsing tags and throwing the error at that point so it can't enter the system. As added safety, stick in a few asserts for apis that get passed tags to ensure they also are only seeing valid data. Bonus: Tweak the parsing loop to skip some work when we get the end marker (zero tag) instead of still looping through all the fields.
Diffstat (limited to 'objectivec/GPBWireFormat.h')
-rw-r--r--objectivec/GPBWireFormat.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/objectivec/GPBWireFormat.h b/objectivec/GPBWireFormat.h
index 29cf2f0b..c5941a38 100644
--- a/objectivec/GPBWireFormat.h
+++ b/objectivec/GPBWireFormat.h
@@ -53,6 +53,7 @@ uint32_t GPBWireFormatMakeTag(uint32_t fieldNumber, GPBWireFormat wireType)
__attribute__((const));
GPBWireFormat GPBWireFormatGetTagWireType(uint32_t tag) __attribute__((const));
uint32_t GPBWireFormatGetTagFieldNumber(uint32_t tag) __attribute__((const));
+BOOL GPBWireFormatIsValidTag(uint32_t tag) __attribute__((const));
GPBWireFormat GPBWireFormatForType(GPBDataType dataType, BOOL isPacked)
__attribute__((const));