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
This commit is contained in:
Jonas Ådahl 2016-03-06 11:53:27 +08:00
parent 2d65b485fd
commit 0882bce989

View File

@ -93,7 +93,7 @@ G_DECLARE_DERIVABLE_TYPE (MetaStartupNotificationSequence,
typedef struct { typedef struct {
gchar *id; gchar *id;
time_t timestamp; gint64 timestamp;
} MetaStartupNotificationSequencePrivate; } MetaStartupNotificationSequencePrivate;
struct _MetaStartupNotificationSequenceClass { struct _MetaStartupNotificationSequenceClass {
@ -385,9 +385,12 @@ meta_startup_notification_sequence_x11_class_init (MetaStartupNotificationSequen
static MetaStartupNotificationSequence * static MetaStartupNotificationSequence *
meta_startup_notification_sequence_x11_new (SnStartupSequence *seq) 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, return g_object_new (META_TYPE_STARTUP_NOTIFICATION_SEQUENCE_X11,
"id", sn_startup_sequence_get_id (seq), "id", sn_startup_sequence_get_id (seq),
"timestamp", sn_startup_sequence_get_timestamp (seq) * 1000, "timestamp", timestamp,
"seq", seq, "seq", seq,
NULL); NULL);
} }