[mutter] startup-notification: Ensure provided timestamp is always a 64 bit integer



commit 0882bce989e28f63408e44bc2050997f3f8d220d
Author: Jonas Ådahl <jadahl gmail com>
Date:   Sun Mar 6 11:53:27 2016 +0800

    startup-notification: Ensure provided timestamp is always a 64 bit integer
    
    The libsn API provides its timestamps in the "Time" X11 type, which is
    usually is a typedef for "unsigned long". The type of the "timestamp"
    parameter of StartupNotificationSequence is a signed 64 bit integer.
    When building on an architecture where a "unsigned long" is not 64 bit,
    we'd then pass a 32 bit unsigned integer via a va_list where a signed 64
    bit integer is expected causing va_arg to read past the passed 32 bit
    unsigned integer.
    
    Fix this by ensuring that we always pass the expected type via the
    va_list. Also change the internal timestamp type from time_t (which
    size is undefined) to gint64, to avoid any potential overflow issues.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=762763

 src/core/startup-notification.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/src/core/startup-notification.c b/src/core/startup-notification.c
index 561ddef..cb58c9e 100644
--- a/src/core/startup-notification.c
+++ b/src/core/startup-notification.c
@@ -93,7 +93,7 @@ G_DECLARE_DERIVABLE_TYPE (MetaStartupNotificationSequence,
 
 typedef struct {
   gchar *id;
-  time_t timestamp;
+  gint64 timestamp;
 } MetaStartupNotificationSequencePrivate;
 
 struct _MetaStartupNotificationSequenceClass {
@@ -385,9 +385,12 @@ meta_startup_notification_sequence_x11_class_init (MetaStartupNotificationSequen
 static MetaStartupNotificationSequence *
 meta_startup_notification_sequence_x11_new (SnStartupSequence *seq)
 {
+  gint64 timestamp;
+
+  timestamp = sn_startup_sequence_get_timestamp (seq) * 1000;
   return g_object_new (META_TYPE_STARTUP_NOTIFICATION_SEQUENCE_X11,
                        "id", sn_startup_sequence_get_id (seq),
-                       "timestamp", sn_startup_sequence_get_timestamp (seq) * 1000,
+                       "timestamp", timestamp,
                        "seq", seq,
                        NULL);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]