You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2020/09/28 16:01:37 UTC

[GitHub] [arrow] pitrou opened a new pull request #8290: ARROW-10119: [C++] Fix Parquet crashes on invalid input

pitrou opened a new pull request #8290:
URL: https://github.com/apache/arrow/pull/8290


   Should fix the following issues (found by OSS-Fuzz):
   - https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25901
   - https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25933
   - https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25955
   - https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25957
   - https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25959


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] pitrou commented on pull request #8290: ARROW-10119: [C++] Fix Parquet crashes on invalid input

Posted by GitBox <gi...@apache.org>.
pitrou commented on pull request #8290:
URL: https://github.com/apache/arrow/pull/8290#issuecomment-700799904


   CI failure is just a docker cache issue.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] emkornfield commented on a change in pull request #8290: ARROW-10119: [C++] Fix Parquet crashes on invalid input

Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #8290:
URL: https://github.com/apache/arrow/pull/8290#discussion_r496358278



##########
File path: cpp/src/parquet/column_reader.cc
##########
@@ -374,14 +381,10 @@ std::shared_ptr<Page> SerializedPageReader::NextPage() {
 
       page_buffer = decryption_buffer_;
     }
-    // Uncompress it if we need to
-    if (decompressor_ != nullptr) {
-      page_buffer = DecompressPage(compressed_len, uncompressed_len, page_buffer->data());
-    }
 
-    const PageType::type page_type = LoadEnumSafe(&current_page_header_.type);
+    current_page_type_ = LoadEnumSafe(&current_page_header_.type);

Review comment:
       sorry, its not immediately obvious why thi sis becoming a member?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] emkornfield commented on a change in pull request #8290: ARROW-10119: [C++] Fix Parquet crashes on invalid input

Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #8290:
URL: https://github.com/apache/arrow/pull/8290#discussion_r496358768



##########
File path: cpp/src/parquet/column_reader.cc
##########
@@ -391,10 +394,14 @@ std::shared_ptr<Page> SerializedPageReader::NextPage() {
         throw ParquetException("Invalid page header (negative number of values)");
       }
 
+      // Uncompress if needed

Review comment:
       nit: might be better to name the method something like the comment.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] pitrou commented on a change in pull request #8290: ARROW-10119: [C++] Fix Parquet crashes on invalid input

Posted by GitBox <gi...@apache.org>.
pitrou commented on a change in pull request #8290:
URL: https://github.com/apache/arrow/pull/8290#discussion_r496548609



##########
File path: cpp/src/parquet/column_reader.cc
##########
@@ -374,14 +381,10 @@ std::shared_ptr<Page> SerializedPageReader::NextPage() {
 
       page_buffer = decryption_buffer_;
     }
-    // Uncompress it if we need to
-    if (decompressor_ != nullptr) {
-      page_buffer = DecompressPage(compressed_len, uncompressed_len, page_buffer->data());
-    }
 
-    const PageType::type page_type = LoadEnumSafe(&current_page_header_.type);
+    current_page_type_ = LoadEnumSafe(&current_page_header_.type);

Review comment:
       Hmm, this was needed in a previous version of this patch, but I'll revert.

##########
File path: cpp/src/parquet/column_reader.cc
##########
@@ -391,10 +394,14 @@ std::shared_ptr<Page> SerializedPageReader::NextPage() {
         throw ParquetException("Invalid page header (negative number of values)");
       }
 
+      // Uncompress if needed

Review comment:
       Will do :-)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] github-actions[bot] commented on pull request #8290: ARROW-10119: [C++] Fix Parquet crashes on invalid input

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #8290:
URL: https://github.com/apache/arrow/pull/8290#issuecomment-700131930


   https://issues.apache.org/jira/browse/ARROW-10119


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] emkornfield commented on pull request #8290: ARROW-10119: [C++] Fix Parquet crashes on invalid input

Posted by GitBox <gi...@apache.org>.
emkornfield commented on pull request #8290:
URL: https://github.com/apache/arrow/pull/8290#issuecomment-700406459


   A few small comments otherwise LGTM.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] pitrou closed pull request #8290: ARROW-10119: [C++] Fix Parquet crashes on invalid input

Posted by GitBox <gi...@apache.org>.
pitrou closed pull request #8290:
URL: https://github.com/apache/arrow/pull/8290


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] emkornfield commented on a change in pull request #8290: ARROW-10119: [C++] Fix Parquet crashes on invalid input

Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #8290:
URL: https://github.com/apache/arrow/pull/8290#discussion_r496357083



##########
File path: cpp/src/parquet/arrow/schema.cc
##########
@@ -834,16 +834,23 @@ Status SchemaManifest::Make(const SchemaDescriptor* schema,
                             const std::shared_ptr<const KeyValueMetadata>& metadata,
                             const ArrowReaderProperties& properties,
                             SchemaManifest* manifest) {
-  RETURN_NOT_OK(
-      GetOriginSchema(metadata, &manifest->schema_metadata, &manifest->origin_schema));
-
   SchemaTreeContext ctx;
   ctx.manifest = manifest;
   ctx.properties = properties;
   ctx.schema = schema;
   const GroupNode& schema_node = *schema->group_node();
   manifest->descr = schema;
   manifest->schema_fields.resize(schema_node.field_count());
+
+  // Try to deserialize original Arrow schema
+  RETURN_NOT_OK(
+      GetOriginSchema(metadata, &manifest->schema_metadata, &manifest->origin_schema));
+  // Ignore original schema if it's not compatible with the Parquet schema
+  if (manifest->origin_schema != nullptr &&
+      manifest->origin_schema->num_fields() != schema_node.field_count()) {
+    manifest->origin_schema = nullptr;

Review comment:
       might be worth a log statement here?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] pitrou commented on a change in pull request #8290: ARROW-10119: [C++] Fix Parquet crashes on invalid input

Posted by GitBox <gi...@apache.org>.
pitrou commented on a change in pull request #8290:
URL: https://github.com/apache/arrow/pull/8290#discussion_r496548460



##########
File path: cpp/src/parquet/arrow/schema.cc
##########
@@ -834,16 +834,23 @@ Status SchemaManifest::Make(const SchemaDescriptor* schema,
                             const std::shared_ptr<const KeyValueMetadata>& metadata,
                             const ArrowReaderProperties& properties,
                             SchemaManifest* manifest) {
-  RETURN_NOT_OK(
-      GetOriginSchema(metadata, &manifest->schema_metadata, &manifest->origin_schema));
-
   SchemaTreeContext ctx;
   ctx.manifest = manifest;
   ctx.properties = properties;
   ctx.schema = schema;
   const GroupNode& schema_node = *schema->group_node();
   manifest->descr = schema;
   manifest->schema_fields.resize(schema_node.field_count());
+
+  // Try to deserialize original Arrow schema
+  RETURN_NOT_OK(
+      GetOriginSchema(metadata, &manifest->schema_metadata, &manifest->origin_schema));
+  // Ignore original schema if it's not compatible with the Parquet schema
+  if (manifest->origin_schema != nullptr &&
+      manifest->origin_schema->num_fields() != schema_node.field_count()) {
+    manifest->origin_schema = nullptr;

Review comment:
       Or perhaps it should error out? I don't know.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org