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


##########
cpp/src/parquet/encryption/encryption_internal.cc:
##########
@@ -758,9 +795,14 @@ void QuickUpdatePageAad(int32_t new_page_ordinal, 
std::string* AAD) {
   std::memcpy(AAD->data() + AAD->length() - 2, page_ordinal_bytes.data(), 2);
 }
 
-void RandBytes(unsigned char* buf, int num) {
+void RandBytes(unsigned char* buf, size_t num) {
+  if (num > static_cast<size_t>(std::numeric_limits<int>::max())) {
+    std::stringstream ss;
+    ss << "Length " << num << " for RandBytes overflows int";
+    throw ParquetException(ss.str());
+  }
   openssl::EnsureInitialized();
-  RAND_bytes(buf, num);
+  RAND_bytes(buf, static_cast<int>(num));

Review Comment:
   Could be fixed in another PR, but feel free to add the check here. It 
probably won't fail _in practice_.



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