[glib] gdatetime: Fix a potential overflow in overflow calculations
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gdatetime: Fix a potential overflow in overflow calculations
- Date: Wed, 21 Jun 2017 10:21:51 +0000 (UTC)
commit 2db7aa479919dc7ae8742f52ad5d54191a7282fd
Author: Philip Withnall <withnall endlessm com>
Date: Fri Jun 16 12:31:58 2017 +0100
gdatetime: Fix a potential overflow in overflow calculations
I can’t remember whether glong (tv.tv_sec) needs to be explicitly
promoted to gint64 here, or whether C does it automatically. Safer to
make the cast explicit to avoid overflow issues on 32-bit platforms,
where glong is 32-bit.
Signed-off-by: Philip Withnall <withnall endlessm com>
https://bugzilla.gnome.org/show_bug.cgi?id=783841
glib/gdatetime.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/glib/gdatetime.c b/glib/gdatetime.c
index 7695adf..745a32a 100644
--- a/glib/gdatetime.c
+++ b/glib/gdatetime.c
@@ -128,7 +128,7 @@ struct _GDateTime
#define INSTANT_TO_UNIX(instant) \
((instant)/USEC_PER_SECOND - UNIX_EPOCH_START * SEC_PER_DAY)
#define UNIX_TO_INSTANT(unix) \
- (((unix) + UNIX_EPOCH_START * SEC_PER_DAY) * USEC_PER_SECOND)
+ (((gint64) (unix) + UNIX_EPOCH_START * SEC_PER_DAY) * USEC_PER_SECOND)
#define UNIX_TO_INSTANT_IS_VALID(unix) \
((gint64) (unix) <= INSTANT_TO_UNIX (G_MAXINT64))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]