mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Fix buffer overflow in DateLUT
This commit is contained in:
parent
303db08231
commit
505898747e
@ -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