X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dbus%2Fdbus-marshal-byteswap.c;h=22d7e22bf44fbbb9c1eff9deee0201a9ccfc45c1;hb=ef8d0d75d538db543ab0ff68809656f3972e3848;hp=7670ec45953539aeb0ec1bc855ac964509702bb1;hpb=3ed9db546e1143bc9aa2d83a6f423fdd81227352;p=platform%2Fupstream%2Fdbus.git diff --git a/dbus/dbus-marshal-byteswap.c b/dbus/dbus-marshal-byteswap.c index 7670ec4..22d7e22 100644 --- a/dbus/dbus-marshal-byteswap.c +++ b/dbus/dbus-marshal-byteswap.c @@ -1,4 +1,4 @@ -/* -*- mode: C; c-file-style: "gnu" -*- */ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ /* dbus-marshal-byteswap.c Swap a block of marshaled data * * Copyright (C) 2005 Red Hat, Inc. @@ -17,12 +17,14 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ +#include #include "dbus-marshal-byteswap.h" #include "dbus-marshal-basic.h" +#include "dbus-signature.h" /** * @addtogroup DBusMarshal @@ -89,7 +91,7 @@ byteswap_body_helper (DBusTypeReader *reader, p = _DBUS_ALIGN_ADDRESS (p, 4); array_len = _dbus_unpack_uint32 (old_byte_order, p); - + *((dbus_uint32_t*)p) = DBUS_UINT32_SWAP_LE_BE (*((dbus_uint32_t*)p)); p += 4; @@ -101,12 +103,15 @@ byteswap_body_helper (DBusTypeReader *reader, elem_type = _dbus_type_reader_get_element_type (reader); alignment = _dbus_type_get_alignment (elem_type); + _dbus_assert ((array_len / alignment) < DBUS_MAXIMUM_ARRAY_LENGTH); + p = _DBUS_ALIGN_ADDRESS (p, alignment); - if (_dbus_type_is_fixed (elem_type)) + if (dbus_type_is_fixed (elem_type)) { if (alignment > 1) - _dbus_swap_array (p, array_len / alignment, alignment); + _dbus_swap_array (p, array_len / alignment, alignment); + p += array_len; } else { @@ -175,6 +180,7 @@ byteswap_body_helper (DBusTypeReader *reader, break; case DBUS_TYPE_STRUCT: + case DBUS_TYPE_DICT_ENTRY: { DBusTypeReader sub; @@ -186,6 +192,11 @@ 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;