mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
Fix undefined-behavior in case of too big max_execution_time setting
This commit is contained in:
parent
2c766cf75f
commit
73bbc08384
@ -21,6 +21,7 @@ namespace ErrorCodes
|
||||
extern const int CANNOT_PARSE_BOOL;
|
||||
extern const int CANNOT_PARSE_NUMBER;
|
||||
extern const int CANNOT_CONVERT_TYPE;
|
||||
extern const int BAD_ARGUMENTS;
|
||||
}
|
||||
|
||||
|
||||
@ -268,6 +269,10 @@ namespace
|
||||
if (d != 0.0 && !std::isnormal(d))
|
||||
throw Exception(
|
||||
ErrorCodes::CANNOT_PARSE_NUMBER, "A setting's value in seconds must be a normal floating point number or zero. Got {}", d);
|
||||
if (d * 1000000 > std::numeric_limits<Poco::Timespan::TimeDiff>::max() || d * 1000000 < std::numeric_limits<Poco::Timespan::TimeDiff>::min())
|
||||
throw Exception(
|
||||
ErrorCodes::BAD_ARGUMENTS, "Cannot convert seconds to microseconds: the setting's value in seconds is too big: {}", d);
|
||||
|
||||
return static_cast<Poco::Timespan::TimeDiff>(d * 1000000);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,2 @@
|
||||
select 1 settings max_execution_time = 9223372036854775808; -- {clientError CANNOT_PARSE_NUMBER}
|
||||
|
Loading…
Reference in New Issue
Block a user