dmitry-chirkov-dremio commented on code in PR #50523:
URL: https://github.com/apache/arrow/pull/50523#discussion_r4297030547


##########
cpp/src/gandiva/gdv_function_stubs.cc:
##########
@@ -366,19 +369,16 @@ const char* gdv_fn_aes_encrypt(int64_t context, const 
char* data, int32_t data_l
     return "";
   }
 
-  int64_t kAesBlockSize = 0;
-  if (key_data_len == 16 || key_data_len == 24 || key_data_len == 32) {
-    kAesBlockSize = static_cast<int64_t>(key_data_len);
-  } else {
+  if (key_data_len != 16 && key_data_len != 24 && key_data_len != 32) {
     std::ostringstream oss;
     oss << "invalid key length: " << key_data_len;
     gdv_fn_context_set_error_msg(context, oss.str().c_str());
     *out_len = 0;
     return nullptr;
   }
 
-  *out_len =
-      static_cast<int32_t>(arrow::bit_util::RoundUpToPowerOf2(data_len, 
kAesBlockSize));
+  *out_len = static_cast<int32_t>(

Review Comment:
   The unchecked narrowing (here and below) predates this PR, but adding the 
padding block makes another 16 input lengths overflow. Could we guard the new 
allocation calculation before narrowing, in both stubs?



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