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

Commit4749e91

Browse files
committed
Fix insufficient check for overflow in tm2abstime(), per report from jw.
1 parent37c443e commit4749e91

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.140 2005/07/2203:46:33 momjian Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.141 2005/07/2219:55:50 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -29,7 +29,7 @@
2929
#include"utils/builtins.h"
3030
#include"utils/nabstime.h"
3131

32-
#defineMIN_DAYNUM -24856/* December 13, 1901 */
32+
#defineMIN_DAYNUM(-24856)/* December 13, 1901 */
3333
#defineMAX_DAYNUM 24854/* January 18, 2038 */
3434

3535
#defineINVALID_RELTIME_STR"Undefined RelTime"
@@ -201,9 +201,12 @@ tm2abstime(struct pg_tm *tm, int tz)
201201
/* convert to seconds */
202202
sec=tm->tm_sec+tz+ (tm->tm_min+ (day*HOURS_PER_DAY+tm->tm_hour)*MINS_PER_HOUR)*SECS_PER_MINUTE;
203203

204-
/* check for overflow */
205-
if ((day==MAX_DAYNUM&&sec<0)||
206-
(day==MIN_DAYNUM&&sec>0))
204+
/*
205+
* check for overflow. We need a little slop here because the H/M/S plus
206+
* TZ offset could add up to more than 1 day.
207+
*/
208+
if ((day >=MAX_DAYNUM-10&&sec<0)||
209+
(day <=MIN_DAYNUM+10&&sec>0))
207210
returnINVALID_ABSTIME;
208211

209212
/* check for reserved values (e.g. "current" on edge of usual range */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp