1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-06 07:49:08 +03:00

Fix range check in date_recv that tried to limit accepted values to only

those accepted by date_in(). I confused julian day numbers and number of
days since the postgres epoch 2000-01-01 in the original patch.

I just noticed that it's still easy to get such out-of-range values into
the database using to_date or +- operators, but this patch doesn't do
anything about those functions.

Per report from James Pye.
This commit is contained in:
Heikki Linnakangas
2009-10-26 16:13:11 +00:00
parent 9f2ee8f287
commit 2078e384a3
2 changed files with 5 additions and 4 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.148 2009/09/04 11:20:22 heikki Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.149 2009/10/26 16:13:11 heikki Exp $
*
*-------------------------------------------------------------------------
*/
@@ -208,7 +208,8 @@ date_recv(PG_FUNCTION_ARGS)
result = (DateADT) pq_getmsgint(buf, sizeof(DateADT));
/* Limit to the same range that date_in() accepts. */
if (result < 0 || result > JULIAN_MAX)
if (result < -POSTGRES_EPOCH_JDATE ||
result >= JULIAN_MAX - POSTGRES_EPOCH_JDATE)
ereport(ERROR,
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
errmsg("date out of range")));