Github user omalley commented on a diff in the pull request:
https://github.com/apache/orc/pull/231#discussion_r175950941
--- Diff: c++/src/Reader.cc ---
@@ -897,6 +897,27 @@ namespace orc {
return REDUNDANT_MOVE(postscript);
}
+ // ORC-317: check that indices in the type tree are valid, so we won't
crash
+ // when we convert the proto::Types to TypeImpls.
+ void checkProtoTypeIds(int &index, const proto::Footer &footer) {
+ if (index >= footer.types_size())
+ throw ParseError(std::string("Footer is corrupt that it lost
types(") +
+ std::to_string(index) + ")");
+ const proto::Type& type = footer.types(index);
+
+ int origin_index = index;
+ for (int i = 0; i < type.subtypes_size(); ++i) {
+ int proto_index = static_cast<int>(type.subtypes(i));
--- End diff --
For each type:
- For each subtype value:
+ ensure it is larger than the parent type id
+ ensure it is larger than the previous subtype
+ ensure it is lower or equal to than the max type id
That should prevent any failures, even with malformed ORC file footers.
---