mirror of
https://github.com/postgres/postgres.git
synced 2025-09-09 13:09:39 +03:00
Add checks for interval overflow/underflow
New checks include input, month/day/time internal adjustments, addition, subtraction, multiplication, and negation. Also adjust docs to correctly specify interval size in bytes. Report from Rok Kralj
This commit is contained in:
@@ -1036,6 +1036,9 @@ recalc:
|
||||
static int
|
||||
tm2interval(struct tm * tm, fsec_t fsec, interval * span)
|
||||
{
|
||||
if ((double)tm->tm_year * MONTHS_PER_YEAR + tm->tm_mon > INT_MAX ||
|
||||
(double)tm->tm_year * MONTHS_PER_YEAR + tm->tm_mon < INT_MIN)
|
||||
return -1;
|
||||
span->month = tm->tm_year * MONTHS_PER_YEAR + tm->tm_mon;
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
span->time = (((((((tm->tm_mday * INT64CONST(24)) +
|
||||
|
Reference in New Issue
Block a user