Repository: orc Updated Branches: refs/heads/master 2926f325a -> 65c5eeff1
ORC-314: [C++] Check scale range when parsing decimals Fixes #226 Signed-off-by: Deepak Majeti <mdee...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/orc/repo Commit: http://git-wip-us.apache.org/repos/asf/orc/commit/65c5eeff Tree: http://git-wip-us.apache.org/repos/asf/orc/tree/65c5eeff Diff: http://git-wip-us.apache.org/repos/asf/orc/diff/65c5eeff Branch: refs/heads/master Commit: 65c5eeff12f8c80481d1e8cb51ab685495319e25 Parents: 2926f32 Author: stiga-huang <huangquanl...@gmail.com> Authored: Sun Mar 4 17:51:30 2018 -0800 Committer: Deepak Majeti <mdee...@apache.org> Committed: Tue Mar 6 21:52:43 2018 -0500 ---------------------------------------------------------------------- c++/src/ColumnReader.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/orc/blob/65c5eeff/c++/src/ColumnReader.cc ---------------------------------------------------------------------- diff --git a/c++/src/ColumnReader.cc b/c++/src/ColumnReader.cc index 53997a4..24f0820 100644 --- a/c++/src/ColumnReader.cc +++ b/c++/src/ColumnReader.cc @@ -1182,10 +1182,14 @@ namespace orc { } } value = unZigZag(static_cast<uint64_t>(value)); - if (scale > currentScale) { + if (scale > currentScale && + static_cast<uint64_t>(scale - currentScale) <= MAX_PRECISION_64) { value *= POWERS_OF_TEN[scale - currentScale]; - } else if (scale < currentScale) { + } else if (scale < currentScale && + static_cast<uint64_t>(currentScale - scale) <= MAX_PRECISION_64) { value /= POWERS_OF_TEN[currentScale - scale]; + } else if (scale != currentScale) { + throw ParseError("Decimal scale out of range"); } }