Arawoof06 commented on code in PR #50523:
URL: https://github.com/apache/arrow/pull/50523#discussion_r4304128053
##########
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:
Makes sense to fix it here since the padding block is what adds those
lengths. Both stubs now compute the size as int64 and set an error before the
narrowing if it's above INT32_MAX. Added TestAesOutputSizeOverflow, which
covers INT32_MAX - 15 and INT32_MAX for encrypt and decrypt.
--
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]