pitrou commented on code in PR #43222:
URL: https://github.com/apache/arrow/pull/43222#discussion_r1679562888


##########
cpp/src/parquet/encryption/encryption_internal_nossl.cc:
##########
@@ -70,14 +70,13 @@ void AesDecryptor::WipeOut() { 
ThrowOpenSSLRequiredException(); }
 
 AesDecryptor::~AesDecryptor() {}
 
-AesEncryptor* AesEncryptor::Make(ParquetCipher::type alg_id, int key_len, bool 
metadata,
-                                 std::vector<AesEncryptor*>* all_encryptors) {
+std::unique_ptr<AesEncryptor> AesEncryptor::Make(ParquetCipher::type alg_id, 
int key_len,
+                                                 bool metadata) {
   return NULLPTR;

Review Comment:
   Can we throw an exception here instead (also in similar methods like 
`AesDecryptor::Make`?



##########
cpp/src/parquet/encryption/internal_file_decryptor.cc:
##########
@@ -154,11 +154,15 @@ std::shared_ptr<Decryptor> 
InternalFileDecryptor::GetFooterDecryptor(
     aes_data_decryptor = encryption::AesDecryptor::Make(
         algorithm_, key_len, /*metadata=*/false, &all_decryptors_);
   }
+  if (ARROW_PREDICT_FALSE(aes_metadata_decryptor == nullptr ||
+                          aes_data_decryptor == nullptr)) {
+    throw ParquetException("Failed to create AES decryptor");

Review Comment:
   This shouldn't be necessary if we throw in `encryption_internal_nossl.c`, 
and then we'll get a more useful error message.



##########
cpp/src/parquet/encryption/internal_file_encryptor.cc:
##########
@@ -52,8 +52,15 @@ 
InternalFileEncryptor::InternalFileEncryptor(FileEncryptionProperties* propertie
 void InternalFileEncryptor::WipeOutEncryptionKeys() {
   properties_->WipeOutEncryptionKeys();
 
-  for (auto const& i : all_encryptors_) {
-    i->WipeOut();
+  for (auto const& i : meta_encryptor_) {
+    if (i != nullptr) {

Review Comment:
   If we ensure that `AesEncryptor::Make` and `AesDecryptor::Make` always 
return a non-null value, we don't need those checks.



##########
cpp/src/parquet/metadata.cc:
##########
@@ -662,7 +665,7 @@ class FileMetaData::FileMetaDataImpl {
         encrypted_buffer->mutable_data());
     // Delete AES encryptor object. It was created only to verify the footer 
signature.
     aes_encryptor->WipeOut();
-    delete aes_encryptor;
+    aes_encryptor = nullptr;

Review Comment:
   What's the point of this? `aes_encryptor` is just a local variable.



-- 
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: github-unsubscr...@arrow.apache.org

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

Reply via email to