Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

stiga-huang
Copy link
Contributor

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.

@stiga-huang
Copy link
Contributor Author

@omalley @majetideepak could you have a look at these? We need this bug be fixed to integrate the c++ library into Impala (ORC-315).

Copy link
Contributor

@omalley omalley left a 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.

@@ -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) {
Copy link
Contributor

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.


int origin_index = index;
for (int i = 0; i < type.subtypes_size(); ++i) {
int proto_index = static_cast<int>(type.subtypes(i));
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's cool!

Copy link
Contributor

@majetideepak majetideepak left a 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!

@asfgit asfgit closed this in c1348d0 Mar 23, 2018
@omalley
Copy link
Contributor

omalley commented Mar 23, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants