Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2078e38

Browse files
committed
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 ofdays 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 intothe database using to_date or +- operators, but this patch doesn't doanything about those functions.Per report from James Pye.
1 parent9f2ee8f commit2078e38

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

‎src/backend/utils/adt/date.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.148 2009/09/04 11:20:22 heikki Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.149 2009/10/26 16:13:11 heikki Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -208,7 +208,8 @@ date_recv(PG_FUNCTION_ARGS)
208208
result= (DateADT)pq_getmsgint(buf,sizeof(DateADT));
209209

210210
/* Limit to the same range that date_in() accepts. */
211-
if (result<0||result>JULIAN_MAX)
211+
if (result<-POSTGRES_EPOCH_JDATE||
212+
result >=JULIAN_MAX-POSTGRES_EPOCH_JDATE)
212213
ereport(ERROR,
213214
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
214215
errmsg("date out of range")));

‎src/include/utils/datetime.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
1010
* Portions Copyright (c) 1994, Regents of the University of California
1111
*
12-
* $PostgreSQL: pgsql/src/include/utils/datetime.h,v 1.76 2009/09/04 11:20:23 heikki Exp $
12+
* $PostgreSQL: pgsql/src/include/utils/datetime.h,v 1.77 2009/10/26 16:13:11 heikki Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -262,7 +262,7 @@ extern const int day_tab[2][13];
262262
|| (((m) == JULIAN_MINMONTH) && ((d) >= JULIAN_MINDAY))))) \
263263
&& ((y) < JULIAN_MAXYEAR))
264264

265-
#defineJULIAN_MAX (2145031948)/* == date2j(JULIAN_MAXYEAR, 1 ,1) */
265+
#defineJULIAN_MAX (2147483494)/* == date2j(JULIAN_MAXYEAR, 1 ,1) */
266266

267267
/* Julian-date equivalents of Day 0 in Unix and Postgres reckoning */
268268
#defineUNIX_EPOCH_JDATE2440588/* == date2j(1970, 1, 1) */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp