aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-01-23 21:26:13 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-01-23 21:26:13 +0000
commitb9ff7443e63f25f73d45b35afe65a85d98a57256 (patch)
tree18445a20e8cdf05b406e6ccb9c8892e7660ce1b7 /src
parent1570d0467af81e652e2e9f89ba6c8508cc118255 (diff)
downloadpostgresql-b9ff7443e63f25f73d45b35afe65a85d98a57256.tar.gz
postgresql-b9ff7443e63f25f73d45b35afe65a85d98a57256.zip
Prevent integer overflow within the integer-datetimes version of
TimestampTzPlusMilliseconds. An integer argument of more than INT_MAX/1000 milliseconds (ie, about 35 minutes) would provoke a wrong result, resulting in incorrect enforcement of statement_timestamp values larger than that. Bug was introduced in my rewrite of 2006-06-20, which fixed some other overflow risks, but missed this one :-( Per report from Elein.
Diffstat (limited to 'src')
-rw-r--r--src/include/utils/timestamp.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/include/utils/timestamp.h b/src/include/utils/timestamp.h
index a12b180862f..1f73a2a081a 100644
--- a/src/include/utils/timestamp.h
+++ b/src/include/utils/timestamp.h
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/utils/timestamp.h,v 1.73 2008/01/01 19:45:59 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/utils/timestamp.h,v 1.74 2008/01/23 21:26:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -182,7 +182,7 @@ typedef double fsec_t;
#define INTERVAL_RANGE(t) (((t) >> 16) & INTERVAL_RANGE_MASK)
#ifdef HAVE_INT64_TIMESTAMP
-#define TimestampTzPlusMilliseconds(tz,ms) ((tz) + ((ms) * 1000))
+#define TimestampTzPlusMilliseconds(tz,ms) ((tz) + ((ms) * (int64) 1000))
#else
#define TimestampTzPlusMilliseconds(tz,ms) ((tz) + ((ms) / 1000.0))
#endif