Function toDateTime decimal overflow ubsan fix

This commit is contained in:
Maksim Kita 2021-04-19 02:00:33 +03:00
parent 366ef28d66
commit 1bfd4f7568
3 changed files with 6 additions and 1 deletions

View File

@ -103,7 +103,10 @@ inline DecimalType decimalFromComponentsWithMultiplier(
if (common::mulOverflow(whole, scale_multiplier, whole_scaled)) if (common::mulOverflow(whole, scale_multiplier, whole_scaled))
throw Exception("Decimal math overflow", ErrorCodes::DECIMAL_OVERFLOW); throw Exception("Decimal math overflow", ErrorCodes::DECIMAL_OVERFLOW);
const T value = whole_scaled + fractional_sign * (fractional % scale_multiplier); T value;
if (common::addOverflow(whole_scaled, fractional_sign * (fractional % scale_multiplier), value))
throw Exception("Decimal math overflow", ErrorCodes::DECIMAL_OVERFLOW);
return DecimalType(value); return DecimalType(value);
} }

View File

@ -0,0 +1,2 @@
SELECT toDateTime('9223372036854775806', 7); -- { serverError 407 }
SELECT toDateTime('9223372036854775806', 8); -- { serverError 407 }