dbus: a couple of corrections after static analysis 84/180884/1
authorAdrian Szyndela <adrian.s@samsung.com>
Tue, 5 Jun 2018 07:33:47 +0000 (09:33 +0200)
committerAdrian Szyndela <adrian.s@samsung.com>
Tue, 5 Jun 2018 07:37:38 +0000 (09:37 +0200)
dbus-transport-kdbus.c:900
SVACE 19383: Assignment of a signed value which has type 'int'
to a variable of a bigger integer type 'dbus_uint64_t'

dbus-transport-kdbus.c:2464
SVACE 2044: Checking return value of dbus_message_get_interface().

Change-Id: Ic793c2d414aa77273b9ff3eff83a72b4f3e4d815

dbus/dbus-transport-kdbus.c

index 0683db5..e8b333a 100755 (executable)
@@ -890,14 +890,16 @@ kdbus_write_msg_internal (DBusTransportKdbus  *transport,
         {
           while (body_size > 0)
             {
-              dbus_uint64_t part_size = body_size;
+              dbus_uint32_t part_size;
 
-              if (part_size > KDBUS_MSG_MAX_PAYLOAD_VEC_SIZE)
-                  part_size = KDBUS_MSG_MAX_PAYLOAD_VEC_SIZE;
+              if (body_size < KDBUS_MSG_MAX_PAYLOAD_VEC_SIZE)
+                part_size = body_size;
+              else
+                part_size = KDBUS_MSG_MAX_PAYLOAD_VEC_SIZE;
 
               /* we need to adjust part size if footer does not fit as a whole */
               if (body_size - part_size > 0 && footer_ptr < (body_data + part_size))
-                  part_size = (dbus_uint64_t)(footer_ptr - body_data);
+                  part_size = footer_ptr - body_data;
 
               _dbus_verbose ("attaching body part\n");
               item = _kdbus_item_add_payload_vec (item,
@@ -2461,7 +2463,8 @@ capture_org_freedesktop_DBus (DBusTransportKdbus *transport,
   int ret = 1;
   if (!strcmp (destination, DBUS_SERVICE_DBUS))
     {
-      if (!strcmp (dbus_message_get_interface (message), DBUS_INTERFACE_DBUS))
+      const char *interface = dbus_message_get_interface (message);
+      if (interface && !strcmp (interface, DBUS_INTERFACE_DBUS))
         {
           DBusError error;
           const char *member = dbus_message_get_member (message);