orc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject [orc] 03/04: ORC-414: [C++] Check root type existence before reading files
Date Tue, 22 Oct 2019 23:15:56 GMT
This is an automated email from the ASF dual-hosted git repository.

omalley pushed a commit to branch branch-1.6
in repository https://gitbox.apache.org/repos/asf/orc.git

commit 0635bb34332e2abaed1fbe3673b35506463453b5
Author: stiga-huang <huangquanlong@gmail.com>
AuthorDate: Sat Oct 19 21:51:10 2019 +0800

    ORC-414: [C++] Check root type existence before reading files
    
    Fixes #438
    
    Signed-off-by: Owen O'Malley <omalley@apache.org>
---
 c++/src/Reader.cc    | 3 +++
 c++/test/TestType.cc | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/c++/src/Reader.cc b/c++/src/Reader.cc
index ad87c15..ef39a58 100644
--- a/c++/src/Reader.cc
+++ b/c++/src/Reader.cc
@@ -1014,6 +1014,9 @@ namespace orc {
   void checkProtoTypeIds(const proto::Footer &footer) {
     std::stringstream msg;
     int maxId = footer.types_size();
+    if (maxId <= 0) {
+      throw ParseError("Footer is corrupt: no types found");
+    }
     for (int i = 0; i < maxId; ++i) {
       const proto::Type& type = footer.types(i);
       for (int j = 0; j < type.subtypes_size(); ++j) {
diff --git a/c++/test/TestType.cc b/c++/test/TestType.cc
index 4abfaf1..5d61f6f 100644
--- a/c++/test/TestType.cc
+++ b/c++/test/TestType.cc
@@ -355,6 +355,8 @@ namespace orc {
   TEST(TestType, testCheckProtoTypeIds) {
     proto::Footer footer;
     proto::Type rootType;
+    expectParseError(footer, "Footer is corrupt: no types found");
+
     rootType.set_kind(proto::Type_Kind_STRUCT);
     rootType.add_subtypes(1); // add a non existent type id
     *(footer.add_types()) = rootType;


Mime
View raw message