mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Fix UBsan report in date functions
Found with fuzzer [1]: [1]: https://clickhouse-test-reports.s3.yandex.net/19381/95c9e57ec13e450ec6535cf723f504a2e68e3e2c/fuzzer_ubsan/report.html#fail1
This commit is contained in:
parent
eeafd73890
commit
f2910deec2
@ -87,7 +87,7 @@ struct AddMinutesImpl : public AddOnDateTime64DefaultImpl<AddMinutesImpl>
|
||||
|
||||
static constexpr auto name = "addMinutes";
|
||||
|
||||
static inline UInt32 execute(UInt32 t, Int64 delta, const DateLUTImpl &)
|
||||
static inline NO_SANITIZE_UNDEFINED UInt32 execute(UInt32 t, Int64 delta, const DateLUTImpl &)
|
||||
{
|
||||
return t + delta * 60;
|
||||
}
|
||||
@ -106,7 +106,7 @@ struct AddHoursImpl : public AddOnDateTime64DefaultImpl<AddHoursImpl>
|
||||
|
||||
static constexpr auto name = "addHours";
|
||||
|
||||
static inline UInt32 execute(UInt32 t, Int64 delta, const DateLUTImpl &)
|
||||
static inline NO_SANITIZE_UNDEFINED UInt32 execute(UInt32 t, Int64 delta, const DateLUTImpl &)
|
||||
{
|
||||
return t + delta * 3600;
|
||||
}
|
||||
@ -150,7 +150,7 @@ struct AddWeeksImpl : public AddOnDateTime64DefaultImpl<AddWeeksImpl>
|
||||
|
||||
static constexpr auto name = "addWeeks";
|
||||
|
||||
static inline UInt32 execute(UInt32 t, Int64 delta, const DateLUTImpl & time_zone)
|
||||
static inline NO_SANITIZE_UNDEFINED UInt32 execute(UInt32 t, Int64 delta, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.addWeeks(t, delta);
|
||||
}
|
||||
|
8
tests/queries/0_stateless/01662_date_ubsan.reference
Normal file
8
tests/queries/0_stateless/01662_date_ubsan.reference
Normal file
@ -0,0 +1,8 @@
|
||||
-- { echo }
|
||||
-- tests with INT64_MIN
|
||||
SELECT addMinutes(toDateTime('2021-01-01 00:00:00', 'GMT'), 9223372036854775808);
|
||||
2021-01-01 00:00:00
|
||||
SELECT addHours(toDateTime('2021-01-01 00:00:00', 'GMT'), 9223372036854775808);
|
||||
2021-01-01 00:00:00
|
||||
SELECT addWeeks(toDateTime('2021-01-01 00:00:00', 'GMT'), 9223372036854775808);
|
||||
2021-01-01 00:00:00
|
5
tests/queries/0_stateless/01662_date_ubsan.sql
Normal file
5
tests/queries/0_stateless/01662_date_ubsan.sql
Normal file
@ -0,0 +1,5 @@
|
||||
-- { echo }
|
||||
-- tests with INT64_MIN
|
||||
SELECT addMinutes(toDateTime('2021-01-01 00:00:00', 'GMT'), 9223372036854775808);
|
||||
SELECT addHours(toDateTime('2021-01-01 00:00:00', 'GMT'), 9223372036854775808);
|
||||
SELECT addWeeks(toDateTime('2021-01-01 00:00:00', 'GMT'), 9223372036854775808);
|
Loading…
Reference in New Issue
Block a user