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

Commit542eeba

Browse files
committed
Fix overflow check in tm2timestamp (this time for sure).
I fixed this code back in commit841b4a2, but didn't think carefullyenough about the behavior near zero, which meant it improperly rejected1999-12-31 24:00:00. Per report from Magnus Hagander.
1 parent0ea1f6e commit542eeba

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,8 +1690,9 @@ tm2timestamp(struct pg_tm * tm, fsec_t fsec, int *tzp, Timestamp *result)
16901690
return-1;
16911691
}
16921692
/* check for just-barely overflow (okay except time-of-day wraps) */
1693-
if ((*result<0&&date >=0)||
1694-
(*result >=0&&date<0))
1693+
/* caution: we want to allow 1999-12-31 24:00:00 */
1694+
if ((*result<0&&date>0)||
1695+
(*result>0&&date<-1))
16951696
{
16961697
*result=0;/* keep compiler quiet */
16971698
return-1;

‎src/interfaces/ecpg/pgtypeslib/timestamp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ tm2timestamp(struct tm * tm, fsec_t fsec, int *tzp, timestamp * result)
7676
if ((*result-time) /USECS_PER_DAY!=dDate)
7777
return-1;
7878
/* check for just-barely overflow (okay except time-of-day wraps) */
79-
if ((*result<0&&dDate >=0)||
80-
(*result >=0&&dDate<0))
79+
/* caution: we want to allow 1999-12-31 24:00:00 */
80+
if ((*result<0&&dDate>0)||
81+
(*result>0&&dDate<-1))
8182
return-1;
8283
#else
8384
*result=dDate*SECS_PER_DAY+time;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp