mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Merge pull request #19472 from ClickHouse/date-lut-buffer-overflow
Fix buffer overflow in DateLUT
This commit is contained in:
commit
9baac1204e
@ -229,8 +229,12 @@ public:
|
||||
|
||||
inline UInt8 daysInMonth(UInt16 year, UInt8 month) const
|
||||
{
|
||||
UInt16 idx = year - DATE_LUT_MIN_YEAR;
|
||||
if (unlikely(idx >= DATE_LUT_YEARS))
|
||||
return 31; /// Implementation specific behaviour on overflow.
|
||||
|
||||
/// 32 makes arithmetic more simple.
|
||||
DayNum any_day_of_month = DayNum(years_lut[year - DATE_LUT_MIN_YEAR] + 32 * (month - 1));
|
||||
DayNum any_day_of_month = DayNum(years_lut[idx] + 32 * (month - 1));
|
||||
return lut[any_day_of_month].days_in_month;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
SELECT toDate('2105-12-31') + INTERVAL number MONTH FROM system.numbers LIMIT 25000 FORMAT Null;
|
Loading…
Reference in New Issue
Block a user