AppArmor: do not mix dbus_bool_t with int
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Wed, 10 Feb 2016 13:15:56 +0000 (13:15 +0000)
committerRalf Habacker <ralf.habacker@freenet.de>
Thu, 11 Feb 2016 01:06:02 +0000 (02:06 +0100)
libdbus uses dbus_bool_t for booleans; that type is unsigned 32-bit.
However, libapparmor uses int, which is signed, leading to
-Wpointer-sign warnings when we pass a dbus_bool_t * where an int *
was expected.

This file is Linux-specific, and all Linux platforms have 32-bit int
and an in-memory representation of the integers 0 and 1 that is
independent of signedness, so the previous code was harmless
in practice.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=93069
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
bus/apparmor.c

index 3ba84d8..c679ac5 100644 (file)
@@ -606,7 +606,9 @@ bus_apparmor_allows_acquire_service (DBusConnection     *connection,
   BusAppArmorConfinement *con = NULL;
   DBusString qstr, auxdata;
   dbus_bool_t free_auxdata = FALSE;
-  dbus_bool_t allow = FALSE, audit = TRUE;
+  /* the AppArmor API uses pointers to int for pointers to boolean, and
+   * int is not strictly guaranteed to be the same as dbus_bool_t */
+  int allow = FALSE, audit = TRUE;
   unsigned long pid;
   int res, serrno = 0;
 
@@ -742,8 +744,8 @@ bus_apparmor_allows_send (DBusConnection     *sender,
 #ifdef HAVE_APPARMOR
   BusAppArmorConfinement *src_con = NULL, *dst_con = NULL;
   DBusString qstr, auxdata;
-  dbus_bool_t src_allow = FALSE, dst_allow = FALSE;
-  dbus_bool_t src_audit = TRUE, dst_audit = TRUE;
+  int src_allow = FALSE, dst_allow = FALSE;
+  int src_audit = TRUE, dst_audit = TRUE;
   dbus_bool_t free_auxdata = FALSE;
   unsigned long pid;
   int len, res, src_errno = 0, dst_errno = 0;
@@ -1006,7 +1008,7 @@ bus_apparmor_allows_eavesdropping (DBusConnection     *connection,
 #ifdef HAVE_APPARMOR
   BusAppArmorConfinement *con = NULL;
   DBusString qstr, auxdata;
-  dbus_bool_t allow = FALSE, audit = TRUE;
+  int allow = FALSE, audit = TRUE;
   dbus_bool_t free_auxdata = FALSE;
   unsigned long pid;
   int res, serrno = 0;