mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Merge pull request #4179 from yandex/avoid-overflow-in-function-sleep
Fixed possible overflow in function "sleep" (found by fuzz test with UBSan)
This commit is contained in:
commit
aa06005a32
@ -82,12 +82,11 @@ public:
|
||||
/// We do not sleep if the block is empty.
|
||||
if (size > 0)
|
||||
{
|
||||
unsigned useconds = seconds * (variant == FunctionSleepVariant::PerBlock ? 1 : size) * 1e6;
|
||||
|
||||
/// When sleeping, the query cannot be cancelled. For abitily to cancel query, we limit sleep time.
|
||||
if (useconds > 3000000) /// The choice is arbitrary
|
||||
throw Exception("The maximum sleep time is 3000000 microseconds. Requested: " + toString(useconds), ErrorCodes::TOO_SLOW);
|
||||
if (seconds > 3.0) /// The choice is arbitrary
|
||||
throw Exception("The maximum sleep time is 3 seconds. Requested: " + toString(seconds), ErrorCodes::TOO_SLOW);
|
||||
|
||||
UInt64 useconds = seconds * (variant == FunctionSleepVariant::PerBlock ? 1 : size) * 1e6;
|
||||
::usleep(useconds);
|
||||
}
|
||||
|
||||
|
1
dbms/tests/queries/0_stateless/00833_sleep_overflow.sql
Normal file
1
dbms/tests/queries/0_stateless/00833_sleep_overflow.sql
Normal file
@ -0,0 +1 @@
|
||||
SELECT sleep(4295.967296); -- { serverError 160 }
|
Loading…
Reference in New Issue
Block a user