chiark / gitweb /
logind: fix session-device dbus notify
authorDavid Herrmann <dh.herrmann@gmail.com>
Tue, 1 Oct 2013 15:48:15 +0000 (17:48 +0200)
committerDavid Herrmann <dh.herrmann@gmail.com>
Tue, 1 Oct 2013 15:48:15 +0000 (17:48 +0200)
Had this fix lying around here for some time. Thanks to missing
type-checking for va-args we passed in the actual major/minor values
instead of pointers to it. Fix it by saving the values on the stack first
and passing in the pointers.

src/login/logind-session-device.c

index b45f9eb..27afafa 100644 (file)
@@ -46,9 +46,13 @@ static void session_device_notify(SessionDevice *sd, enum SessionDeviceNotificat
         _cleanup_dbus_message_unref_ DBusMessage *m = NULL;
         _cleanup_free_ char *path = NULL;
         const char *t = NULL;
         _cleanup_dbus_message_unref_ DBusMessage *m = NULL;
         _cleanup_free_ char *path = NULL;
         const char *t = NULL;
+        uint32_t major, minor;
 
         assert(sd);
 
 
         assert(sd);
 
+        major = major(sd->dev);
+        minor = minor(sd->dev);
+
         if (!sd->session->controller)
                 return;
 
         if (!sd->session->controller)
                 return;
 
@@ -68,8 +72,8 @@ static void session_device_notify(SessionDevice *sd, enum SessionDeviceNotificat
         switch (type) {
         case SESSION_DEVICE_RESUME:
                 if (!dbus_message_append_args(m,
         switch (type) {
         case SESSION_DEVICE_RESUME:
                 if (!dbus_message_append_args(m,
-                                              DBUS_TYPE_UINT32, major(sd->dev),
-                                              DBUS_TYPE_UINT32, minor(sd->dev),
+                                              DBUS_TYPE_UINT32, &major,
+                                              DBUS_TYPE_UINT32, &minor,
                                               DBUS_TYPE_UNIX_FD, &sd->fd,
                                               DBUS_TYPE_INVALID))
                         return;
                                               DBUS_TYPE_UNIX_FD, &sd->fd,
                                               DBUS_TYPE_INVALID))
                         return;
@@ -88,8 +92,8 @@ static void session_device_notify(SessionDevice *sd, enum SessionDeviceNotificat
         }
 
         if (t && !dbus_message_append_args(m,
         }
 
         if (t && !dbus_message_append_args(m,
-                                           DBUS_TYPE_UINT32, major(sd->dev),
-                                           DBUS_TYPE_UINT32, minor(sd->dev),
+                                           DBUS_TYPE_UINT32, &major,
+                                           DBUS_TYPE_UINT32, &minor,
                                            DBUS_TYPE_STRING, &t,
                                            DBUS_TYPE_INVALID))
                 return;
                                            DBUS_TYPE_STRING, &t,
                                            DBUS_TYPE_INVALID))
                 return;