From db362e4585ae9de6c189fc8a3ea2bca7dcb5c192 Mon Sep 17 00:00:00 2001 From: nikitamikhaylov Date: Thu, 17 Dec 2020 05:20:56 +0300 Subject: [PATCH] done --- src/Functions/FunctionBase64Conversion.h | 6 +++++- src/Functions/toModifiedJulianDay.cpp | 12 +++++++----- .../01602_modified_julian_day_msan.reference | 1 + .../0_stateless/01602_modified_julian_day_msan.sql | 4 ++++ 4 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 tests/queries/0_stateless/01602_modified_julian_day_msan.reference create mode 100644 tests/queries/0_stateless/01602_modified_julian_day_msan.sql diff --git a/src/Functions/FunctionBase64Conversion.h b/src/Functions/FunctionBase64Conversion.h index 4bc2a779cf4..f266142e95a 100644 --- a/src/Functions/FunctionBase64Conversion.h +++ b/src/Functions/FunctionBase64Conversion.h @@ -158,12 +158,16 @@ public: __msan_unpoison(dst_pos, outlen); source += srclen + 1; - dst_pos += outlen + 1; + dst_pos += outlen; + *dst_pos = '\0'; + dst_pos += 1; dst_offsets[row] = dst_pos - dst; src_offset_prev = src_offsets[row]; } + __msan_unpoison(dst_pos, reserve); + dst_data.resize(dst_pos - dst); return dst_column; diff --git a/src/Functions/toModifiedJulianDay.cpp b/src/Functions/toModifiedJulianDay.cpp index df3066a5005..43ed26f91c5 100644 --- a/src/Functions/toModifiedJulianDay.cpp +++ b/src/Functions/toModifiedJulianDay.cpp @@ -62,11 +62,11 @@ namespace DB typename ColVecTo::Container & vec_to = col_to->getData(); ColumnUInt8::MutablePtr col_null_map_to; - ColumnUInt8::Container * vec_null_map_to [[maybe_unused]] = nullptr; + UInt8 * vec_null_map_to [[maybe_unused]] = nullptr; if constexpr (nullOnErrors) { col_null_map_to = ColumnUInt8::create(input_rows_count); - vec_null_map_to = &col_null_map_to->getData(); + vec_null_map_to = col_null_map_to->getData().data(); } size_t current_offset = 0; @@ -83,12 +83,14 @@ namespace DB { const GregorianDate<> date(read_buffer); vec_to[i] = date.toModifiedJulianDay(); - (*vec_null_map_to)[i] = false; + vec_null_map_to[i] = false; } catch (const Exception & e) { - if (e.code() == ErrorCodes::CANNOT_PARSE_INPUT_ASSERTION_FAILED || e.code() == ErrorCodes::CANNOT_PARSE_DATE) - (*vec_null_map_to)[i] = true; + if (e.code() == ErrorCodes::CANNOT_PARSE_INPUT_ASSERTION_FAILED || e.code() == ErrorCodes::CANNOT_PARSE_DATE) { + vec_to[i] = static_cast(0); + vec_null_map_to[i] = true; + } else throw; } diff --git a/tests/queries/0_stateless/01602_modified_julian_day_msan.reference b/tests/queries/0_stateless/01602_modified_julian_day_msan.reference new file mode 100644 index 00000000000..587579af915 --- /dev/null +++ b/tests/queries/0_stateless/01602_modified_julian_day_msan.reference @@ -0,0 +1 @@ +Ok. diff --git a/tests/queries/0_stateless/01602_modified_julian_day_msan.sql b/tests/queries/0_stateless/01602_modified_julian_day_msan.sql new file mode 100644 index 00000000000..d18665f0bcf --- /dev/null +++ b/tests/queries/0_stateless/01602_modified_julian_day_msan.sql @@ -0,0 +1,4 @@ +SELECT tryBase64Decode(( SELECT countSubstrings(toModifiedJulianDayOrNull('\0'), '') ) AS n, ( SELECT regionIn('l. ') ) AS srocpnuv); -- { serverError 43 } +SELECT countSubstrings(toModifiedJulianDayOrNull('\0'), ''); -- { serverError 43 } +SELECT countSubstrings(toInt32OrNull('123qwe123'), ''); -- { serverError 43 } +SELECT 'Ok.';