From 56d09886e2239abae3b5aaaa1cff51c1871cd054 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Fri, 22 Jan 2021 04:08:10 +0300 Subject: [PATCH] Fix MSan report in AES functions --- src/Functions/FunctionsAES.h | 8 ++++++++ tests/queries/0_stateless/01663_aes_msan.reference | 2 ++ tests/queries/0_stateless/01663_aes_msan.sql | 2 ++ 3 files changed, 12 insertions(+) create mode 100644 tests/queries/0_stateless/01663_aes_msan.reference create mode 100644 tests/queries/0_stateless/01663_aes_msan.sql diff --git a/src/Functions/FunctionsAES.h b/src/Functions/FunctionsAES.h index fea47074649..f9cf688c86a 100644 --- a/src/Functions/FunctionsAES.h +++ b/src/Functions/FunctionsAES.h @@ -303,6 +303,10 @@ private: if constexpr (!std::is_same_v>) { iv_value = iv_column->getDataAt(r); + + /// If the length is zero (empty string is passed) it should be treat as no IV. + if (iv_value.size == 0) + iv_value.data = nullptr; } const auto input_value = input_column->getDataAt(r); @@ -571,6 +575,10 @@ private: if constexpr (!std::is_same_v>) { iv_value = iv_column->getDataAt(r); + + /// If the length is zero (empty string is passed) it should be treat as no IV. + if (iv_value.size == 0) + iv_value.data = nullptr; } auto input_value = input_column->getDataAt(r); diff --git a/tests/queries/0_stateless/01663_aes_msan.reference b/tests/queries/0_stateless/01663_aes_msan.reference new file mode 100644 index 00000000000..e760e58b19d --- /dev/null +++ b/tests/queries/0_stateless/01663_aes_msan.reference @@ -0,0 +1,2 @@ +4DB2B0F12DE073FD063CE5478903DE68 +text diff --git a/tests/queries/0_stateless/01663_aes_msan.sql b/tests/queries/0_stateless/01663_aes_msan.sql new file mode 100644 index 00000000000..1d549aece56 --- /dev/null +++ b/tests/queries/0_stateless/01663_aes_msan.sql @@ -0,0 +1,2 @@ +SELECT hex(encrypt('aes-128-cbc', 'text', 'keykeykeykeykeyk', '')); +SELECT decrypt('aes-128-cbc', encrypt('aes-128-cbc', 'text', 'keykeykeykeykeyk', ''), 'keykeykeykeykeyk', '');