Commit e6263cbe authored by Simon McVittie's avatar Simon McVittie

_dbus_message_remove_unknown_fields: Add

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=100317Reviewed-by: Philip Withnall's avatarPhilip Withnall <withnall@endlessm.com>
Signed-off-by: Simon McVittie's avatarSimon McVittie <smcv@collabora.com>
parent 6f8d8200
......@@ -1514,4 +1514,55 @@ _dbus_header_byteswap (DBusHeader *header,
_dbus_string_set_byte (&header->data, BYTE_ORDER_OFFSET, new_order);
}
/**
* Remove every header field not known to this version of dbus.
*
* @param header the header
* @returns #FALSE if no memory
*/
dbus_bool_t
_dbus_header_remove_unknown_fields (DBusHeader *header)
{
DBusTypeReader array;
DBusTypeReader fields_reader;
_dbus_type_reader_init (&fields_reader,
_dbus_header_get_byte_order (header),
&_dbus_header_signature_str,
FIELDS_ARRAY_SIGNATURE_OFFSET,
&header->data,
FIELDS_ARRAY_LENGTH_OFFSET);
_dbus_type_reader_recurse (&fields_reader, &array);
while (_dbus_type_reader_get_current_type (&array) != DBUS_TYPE_INVALID)
{
DBusTypeReader sub;
unsigned char field_code;
_dbus_type_reader_recurse (&array, &sub);
_dbus_assert (_dbus_type_reader_get_current_type (&sub) == DBUS_TYPE_BYTE);
_dbus_type_reader_read_basic (&sub, &field_code);
if (field_code > DBUS_HEADER_FIELD_LAST)
{
if (!reserve_header_padding (header))
return FALSE;
if (!_dbus_type_reader_delete (&array, &fields_reader))
return FALSE;
correct_header_padding (header);
_dbus_header_cache_invalidate_all (header);
}
else
{
_dbus_type_reader_next (&array);
}
}
return TRUE;
}
/** @} */
......@@ -172,7 +172,6 @@ void _dbus_header_byteswap (DBusHeader *header,
int new_order);
DBUS_PRIVATE_EXPORT
char _dbus_header_get_byte_order (const DBusHeader *header);
dbus_bool_t _dbus_header_remove_unknown_fields (DBusHeader *header);
#endif /* DBUS_MARSHAL_HEADER_H */
......@@ -64,6 +64,8 @@ void _dbus_message_add_counter_link (DBusMessage *message,
DBusList *link);
void _dbus_message_remove_counter (DBusMessage *message,
DBusCounter *counter);
DBUS_PRIVATE_EXPORT
dbus_bool_t _dbus_message_remove_unknown_fields (DBusMessage *message);
DBUS_PRIVATE_EXPORT
DBusMessageLoader* _dbus_message_loader_new (void);
......
......@@ -262,6 +262,18 @@ void _dbus_message_get_unix_fds(DBusMessage *message,
#endif
}
/**
* Remove every header field not known to this version of dbus.
*
* @param message the message
* @returns #FALSE if no memory
*/
dbus_bool_t
_dbus_message_remove_unknown_fields (DBusMessage *message)
{
return _dbus_header_remove_unknown_fields (&message->header);
}
/**
* Sets the serial number of a message.
* This can only be done once on a message.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment