aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2013-03-04 15:13:31 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2013-03-04 15:13:31 -0500
commit542eeba26992305d872be699158cb3ab1c2be6e6 (patch)
treedb767a4a7d1e841003d5aa90380c38950bd47ba7 /src/backend
parent0ea1f6e98fc84f1c5f66cc6355f6e20582295e81 (diff)
downloadpostgresql-542eeba26992305d872be699158cb3ab1c2be6e6.tar.gz
postgresql-542eeba26992305d872be699158cb3ab1c2be6e6.zip
Fix overflow check in tm2timestamp (this time for sure).
I fixed this code back in commit 841b4a2d5, but didn't think carefully enough about the behavior near zero, which meant it improperly rejected 1999-12-31 24:00:00. Per report from Magnus Hagander.
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/utils/adt/timestamp.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c
index 451f4dae70c..1a848f9a33b 100644
--- a/src/backend/utils/adt/timestamp.c
+++ b/src/backend/utils/adt/timestamp.c
@@ -1690,8 +1690,9 @@ tm2timestamp(struct pg_tm * tm, fsec_t fsec, int *tzp, Timestamp *result)
return -1;
}
/* check for just-barely overflow (okay except time-of-day wraps) */
- if ((*result < 0 && date >= 0) ||
- (*result >= 0 && date < 0))
+ /* caution: we want to allow 1999-12-31 24:00:00 */
+ if ((*result < 0 && date > 0) ||
+ (*result > 0 && date < -1))
{
*result = 0; /* keep compiler quiet */
return -1;