mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Merge pull request #23278 from kitaisreal/to-date-time-decimal-overflow-ubsan-fix
Function toDateTime decimal overflow ubsan fix
This commit is contained in:
commit
2f56f8d040
@ -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