adamreeve commented on code in PR #43195:
URL: https://github.com/apache/arrow/pull/43195#discussion_r1671588631


##########
cpp/src/parquet/metadata.cc:
##########
@@ -701,12 +702,12 @@ class FileMetaData::FileMetaDataImpl {
       uint8_t* serialized_data;
       uint32_t serialized_len;
       serializer.SerializeToBuffer(metadata_.get(), &serialized_len, 
&serialized_data);
+      ::arrow::util::span<const uint8_t> serialized_data_span(serialized_data,
+                                                              serialized_len);
 
       // encrypt the footer key
-      std::vector<uint8_t> encrypted_data(encryptor->CiphertextSizeDelta() +
-                                          serialized_len);
-      unsigned encrypted_len =
-          encryptor->Encrypt(serialized_data, serialized_len, 
encrypted_data.data());
+      std::vector<uint8_t> 
encrypted_data(encryptor->CiphertextLength(serialized_len));
+      unsigned encrypted_len = encryptor->Encrypt(serialized_data_span, 
encrypted_data);

Review Comment:
   It doesn't look like there's a good reason for this as far as I can tell, 
it's only used in one place a few lines down to get the offset into the 
encrypted data of the start of the tag, and it doesn't look like the cast is 
necessary to prevent an overflow: 
https://github.com/apache/arrow/blob/df9b8f98a73af6de1eef35a4940ae4bab47736eb/cpp/src/parquet/metadata.cc#L718



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to