1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-30 21:42:05 +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

@ -2976,6 +2976,9 @@ DecodeInterval(char **field, int *ftype, int nf, int range,
type = DTK_MONTH;
if (*field[i] == '-')
val2 = -val2;
if (((double)val * MONTHS_PER_YEAR + val2) > INT_MAX ||
((double)val * MONTHS_PER_YEAR + val2) < INT_MIN)
return DTERR_FIELD_OVERFLOW;
val = val * MONTHS_PER_YEAR + val2;
fval = 0;
}