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:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user