[fix](encrypt) wrong mode arg of encrypt and decrypt function make BE crash (#40726) (#40868)

pick #40726 to branch-2.1
This commit is contained in:
camby
2024-09-15 21:31:00 +08:00
committed by GitHub
parent 0d3b9c3f18
commit f3b1f1c19b
3 changed files with 12 additions and 3 deletions

View File

@ -244,8 +244,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();
@ -371,13 +372,15 @@ struct EncryptionAndDecryptMultiImpl {
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);
}
}

View File

@ -272,3 +272,6 @@ zhang
-- !sql56 --
zhang
-- !sql57 --
\N

View File

@ -226,4 +226,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; """
}