1
0
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:
Bruce Momjian
2014-01-30 09:41:43 -05:00
parent 571addd729
commit 146604ec43
4 changed files with 97 additions and 7 deletions

View File

@@ -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)) +