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-589: [C++] add checks about negative dictionary entry lengths #468

Merged
merged 3 commits into from
Jan 15, 2020

Conversation

boroknagyz
Copy link
Contributor

The library used to have a check for negative dictionary entry lengths.
However we don't have it on current master. It causes a problem because
it will use a negative value (casted to unsigned) to allocate a
DataBuffer. This commit adds the missing check.

Testing

  • added a corrupt orc file and a unit test

The library used to have a check for negative dictionary entry lengths.
However we don't have it on current master. It causes a problem because
it will use a negative value (casted to unsigned) to allocate a
DataBuffer. This commit adds the missing check.

Testing
* added a corrupt orc file and a unit test
@@ -581,6 +581,8 @@ namespace orc {
lengthDecoder->next(lengthArray + 1, dictSize, nullptr);
lengthArray[0] = 0;
for(uint32_t i = 1; i < dictSize + 1; ++i) {
if (lengthArray[i] < 0)
Copy link
Member

Choose a reason for hiding this comment

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

Please add curly brace here even for a single line if-statement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

namespace orc {

TEST(TestCorruptFiles, testNegativeDictEntryLengths) {

Copy link
Member

Choose a reason for hiding this comment

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

remove empty line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


namespace orc {

TEST(TestCorruptFiles, testNegativeDictEntryLengths) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think moving this into TestFileScan.testErrorHandling in TestFileScan.cc is simpler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

@wgtmac wgtmac left a comment

Choose a reason for hiding this comment

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

LGTM +1

@wgtmac wgtmac merged commit 2b012e5 into apache:master Jan 15, 2020
stiga-huang pushed a commit to stiga-huang/orc that referenced this pull request Jan 18, 2020
The library used to have a check for negative dictionary entry lengths.
However we don't have it on current master. It causes a problem because
it will use a negative value (casted to unsigned) to allocate a
DataBuffer. This commit adds the missing check.

This fixes apache#468
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.

None yet

3 participants