Skip to content

Commit

Permalink
move check earlier and add missing cast
Browse files Browse the repository at this point in the history
  • Loading branch information
emkornfield committed Jan 9, 2024
1 parent 2f9c906 commit e7fb451
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cpp/src/parquet/column_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,16 @@ class SerializedPageWriter : public PageWriter {
const uint8_t* output_data_buffer = compressed_data->data();
int64_t output_data_len = compressed_data->size();

if (output_data_len > std::numeric_limits<int32_t>::max()) {
throw ParquetException("Compressed page size overflows to INT32_MAX.");
}

if (data_encryptor_.get()) {
PARQUET_THROW_NOT_OK(encryption_buffer_->Resize(
data_encryptor_->CiphertextSizeDelta() + output_data_len, false));
UpdateEncryption(encryption::kDataPage);
output_data_len = data_encryptor_->Encrypt(compressed_data->data(), output_data_len,
output_data_len = data_encryptor_->Encrypt(compressed_data->data(),
static_cast<int32_t>(output_data_len),
encryption_buffer_->mutable_data());
output_data_buffer = encryption_buffer_->data();
}
Expand All @@ -394,9 +399,6 @@ class SerializedPageWriter : public PageWriter {
throw ParquetException("Uncompressed page size overflows to INT32_MAX.");
}
page_header.__set_uncompressed_page_size(static_cast<int32_t>(uncompressed_size));
if (output_data_len > std::numeric_limits<int32_t>::max()) {
throw ParquetException("Compressed page size overflows to INT32_MAX.");
}
page_header.__set_compressed_page_size(static_cast<int32_t>(output_data_len));

if (page_checksum_verification_) {
Expand Down

0 comments on commit e7fb451

Please sign in to comment.