dbus-marshal-byteswap: Byte-swap Unix fd indexes if needed
[platform/upstream/dbus.git] / dbus / dbus-marshal-byteswap.c
index 43a4f47..7104e9c 100644 (file)
@@ -61,6 +61,7 @@ byteswap_body_helper (DBusTypeReader       *reader,
         case DBUS_TYPE_BOOLEAN:
         case DBUS_TYPE_INT32:
         case DBUS_TYPE_UINT32:
+        case DBUS_TYPE_UNIX_FD:
           {
             p = _DBUS_ALIGN_ADDRESS (p, 4);
             *((dbus_uint32_t*)p) = DBUS_UINT32_SWAP_LE_BE (*((dbus_uint32_t*)p));
@@ -188,11 +189,6 @@ byteswap_body_helper (DBusTypeReader       *reader,
           }
           break;
 
-        case DBUS_TYPE_UNIX_FD:
-          /* fds can only be passed on a local machine, so byte order must always match */
-          _dbus_assert_not_reached("attempted to byteswap unix fds which makes no sense");
-          break;
-
         default:
           _dbus_assert_not_reached ("invalid typecode in supposedly-validated signature");
           break;
@@ -239,7 +235,7 @@ _dbus_marshal_byteswap (const DBusString *signature,
 
   byteswap_body_helper (&reader, TRUE,
                         old_byte_order, new_byte_order,
-                        (unsigned char *) _dbus_string_get_data_len (value_str, value_pos, 0),
+                        _dbus_string_get_udata_len (value_str, value_pos, 0),
                         NULL);
 }