This is an automated email from the ASF dual-hosted git repository. dataroaring pushed a commit to branch branch-3.0 in repository https://gitbox.apache.org/repos/asf/doris.git
commit 4e9d0fb77f187eb549a28982ef8ec6c367aa4d9a Author: camby <camby...@tencent.com> AuthorDate: Sat Sep 14 10:18:55 2024 +0800 [fix](encrypt) wrong mode arg of encrypt and decrypt function make BE crash (#40726) Not supported mode arg in sm4_encrypt and sm4_decrypt make BE crash. Intro by https://github.com/apache/doris/pull/37194 --- be/src/vec/functions/function_encryption.cpp | 9 ++++++--- .../sql_functions/encryption_digest/test_encryption_function.out | 3 +++ .../encryption_digest/test_encryption_function.groovy | 3 +++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/be/src/vec/functions/function_encryption.cpp b/be/src/vec/functions/function_encryption.cpp index f63e9bca1b0..06e9efcfea1 100644 --- a/be/src/vec/functions/function_encryption.cpp +++ b/be/src/vec/functions/function_encryption.cpp @@ -236,8 +236,9 @@ struct EncryptionAndDecryptTwoImpl { if (mode_arg.size != 0) { if (!aes_mode_map.contains(mode_str)) { all_insert_null = true; + } else { + encryption_mode = aes_mode_map.at(mode_str); } - encryption_mode = aes_mode_map.at(mode_str); } const ColumnString::Offsets* offsets_column = &column->get_offsets(); const ColumnString::Chars* chars_column = &column->get_chars(); @@ -346,13 +347,15 @@ struct EncryptionAndDecryptFourImpl { if constexpr (is_sm_mode) { if (sm4_mode_map.count(mode_str) == 0) { all_insert_null = true; + } else { + encryption_mode = sm4_mode_map.at(mode_str); } - encryption_mode = sm4_mode_map.at(mode_str); } else { if (aes_mode_map.count(mode_str) == 0) { all_insert_null = true; + } else { + encryption_mode = aes_mode_map.at(mode_str); } - encryption_mode = aes_mode_map.at(mode_str); } } diff --git a/regression-test/data/query_p0/sql_functions/encryption_digest/test_encryption_function.out b/regression-test/data/query_p0/sql_functions/encryption_digest/test_encryption_function.out index 1a46d127eae..8fafcf22ce0 100644 --- a/regression-test/data/query_p0/sql_functions/encryption_digest/test_encryption_function.out +++ b/regression-test/data/query_p0/sql_functions/encryption_digest/test_encryption_function.out @@ -332,3 +332,6 @@ zhang -- !sql56 -- zhang +-- !sql57 -- +\N + diff --git a/regression-test/suites/query_p0/sql_functions/encryption_digest/test_encryption_function.groovy b/regression-test/suites/query_p0/sql_functions/encryption_digest/test_encryption_function.groovy index 985a2d1b4f7..499bf84936b 100644 --- a/regression-test/suites/query_p0/sql_functions/encryption_digest/test_encryption_function.groovy +++ b/regression-test/suites/query_p0/sql_functions/encryption_digest/test_encryption_function.groovy @@ -284,4 +284,7 @@ suite("test_encryption_function") { qt_sql54 """ select aes_decrypt(aes_encrypt(k,k1,k2, "AES_256_CFB"),k1,k2, "AES_256_CFB") from quantile_table2; """ qt_sql55 """ select aes_decrypt(aes_encrypt("zhang",k1,k2, "AES_256_CFB"),k1,k2, "AES_256_CFB") from quantile_table2; """ qt_sql56 """ select aes_decrypt(aes_encrypt("zhang",k1,k2, "AES_256_CFB"),k1,k2, "AES_256_CFB") from quantile_table2; """ + + //four arg (column/const) with wrong mode + qt_sql57 """ select sm4_decrypt(sm4_encrypt(k,"doris","abcdefghij", "SM4_128_CBC"),"doris","abcdefghij","SM4_555_CBC") from quantile_table2; """ } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org