Skip to content

ORC-312: [C++] Fix buffer overflow in corrupt StringDictionaryColumn#224

Closed
stiga-huang wants to merge 3 commits into
apache:masterfrom
stiga-huang:fix-mem-corrupt
Closed

ORC-312: [C++] Fix buffer overflow in corrupt StringDictionaryColumn#224
stiga-huang wants to merge 3 commits into
apache:masterfrom
stiga-huang:fix-mem-corrupt

Conversation

@stiga-huang
Copy link
Copy Markdown
Contributor

The crash is due to the buffer overflow in orc::readFully which only used in StringDictionaryColumnReader currently. The decoded length may larger than we expected if the file is corrupt.

This patch also adds checks for the range of entry indices in StringDictionaryColumnReader::next.

@stiga-huang stiga-huang changed the title ORC-312: fix buffer overflow in corrupt StringDictionaryColumn ORC-312: [C++] Fix buffer overflow in corrupt StringDictionaryColumn Mar 3, 2018
In the constructor of StringDictionaryColumnReader, if there're
negative values in the decoded lengthArray, the calculated blobSize
may be negative. It will be transformed to a huge unsigned integer.
Finally, we crash on DataBuffer::resize
    dictionaryBlob.resize(static_cast<uint64_t>(blobSize))

This patch checks for negative length and throws ParseError in time.
@asfgit asfgit closed this in 2926f32 Mar 7, 2018
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.

2 participants