-
Notifications
You must be signed in to change notification settings - Fork 483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ORC-317: [C++] check that indices in the protobuf type tree are valid #231
Conversation
@omalley @majetideepak could you have a look at these? We need this bug be fixed to integrate the c++ library into Impala (ORC-315). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good change, but I think we can make it direct.
c++/src/Reader.cc
Outdated
@@ -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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest only passing in the footer here and check all of the types in a loop.
c++/src/Reader.cc
Outdated
|
||
int origin_index = index; | ||
for (int i = 0; i < type.subtypes_size(); ++i) { | ||
int proto_index = static_cast<int>(type.subtypes(i)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's cool!
edece2b
to
8107d12
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will merge this in later today!
Actually, I just committed it. Thanks! I did adjust the comment on the code to make it more consistent and remove the jira reference. The git history does that better if we need to track the history. |
A corrupt file may contain loops in the protobuf type tree. We should check this before invoking
convertType
. The file attached to the Jira can reproduce this bug. Tests are added for coverage.