mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-03 13:02:00 +00:00
Function toDateTime decimal overflow ubsan fix
This commit is contained in:
parent
366ef28d66
commit
1bfd4f7568
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
tests/queries/0_stateless/01821_to_date_time_ubsan.sql
Normal file
2
tests/queries/0_stateless/01821_to_date_time_ubsan.sql
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
SELECT toDateTime('9223372036854775806', 7); -- { serverError 407 }
|
||||||
|
SELECT toDateTime('9223372036854775806', 8); -- { serverError 407 }
|
Loading…
Reference in New Issue
Block a user