Skip to content

Commit b9ff744

Browse files
committed
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.
1 parent 1570d04 commit b9ff744

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/include/utils/timestamp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/utils/timestamp.h,v 1.73 2008/01/01 19:45:59 momjian Exp $
9+
* $PostgreSQL: pgsql/src/include/utils/timestamp.h,v 1.74 2008/01/23 21:26:13 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -182,7 +182,7 @@ typedef double fsec_t;
182182
#define INTERVAL_RANGE(t) (((t) >> 16) & INTERVAL_RANGE_MASK)
183183

184184
#ifdef HAVE_INT64_TIMESTAMP
185-
#define TimestampTzPlusMilliseconds(tz,ms) ((tz) + ((ms) * 1000))
185+
#define TimestampTzPlusMilliseconds(tz,ms) ((tz) + ((ms) * (int64) 1000))
186186
#else
187187
#define TimestampTzPlusMilliseconds(tz,ms) ((tz) + ((ms) / 1000.0))
188188
#endif

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy