mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-03 06:38:00 +02:00
2003-03-16 Anders Carlsson <andersca@codefactory.se>
* dbus/dbus-connection.c: (dbus_connection_send_with_reply_and_block): Decrease connection->n_incoming when removing an entry from the list. * dbus/dbus-dict.c: (dbus_dict_entry_free), (dbus_dict_set_boolean_array), (dbus_dict_set_int32_array), (dbus_dict_set_uint32_array), (dbus_dict_set_double_array), (dbus_dict_set_byte_array), (dbus_dict_set_string_array), (dbus_dict_get_boolean_array), (dbus_dict_get_double_array), (dbus_dict_get_byte_array): Handle NULL arrays and strings. Also add support for byte arrays. * dbus/dbus-marshal.c: (_dbus_marshal_byte_array), (_dbus_marshal_dict), (_dbus_demarshal_byte_array), (_dbus_demarshal_int32_array), (_dbus_demarshal_uint32_array), (_dbus_demarshal_double_array), (_dbus_demarshal_string_array), (_dbus_demarshal_dict), (demarshal_and_validate_len), (_dbus_marshal_validate_arg), (_dbus_marshal_test): * dbus/dbus-marshal.h: Add support for marshalling and demarshalling empty arrays and strings. * dbus/dbus-message.c: (dbus_message_append_args_valist), (dbus_message_append_string_array), (dbus_message_iter_get_boolean), (dbus_message_iter_get_boolean_array), (dbus_message_iter_get_int32_array), (dbus_message_iter_get_uint32_array), (dbus_message_iter_get_double_array), (dbus_message_iter_get_byte_array), (dbus_message_iter_get_string_array), (dbus_message_iter_get_dict), (check_message_handling): Add support for getting empty arrays and dicts. * dbus/dbus-string.c: (_dbus_string_validate_utf8): Don't do any validation at all for now, that's better than just checking for ASCII. * test/data/valid-messages/emptiness.message: New test message with lots of empty arrays.
This commit is contained in:
parent
5c53fb2a36
commit
e537e421ff
8 changed files with 508 additions and 257 deletions
42
ChangeLog
42
ChangeLog
|
|
@ -1,3 +1,45 @@
|
|||
2003-03-16 Anders Carlsson <andersca@codefactory.se>
|
||||
|
||||
* dbus/dbus-connection.c:
|
||||
(dbus_connection_send_with_reply_and_block):
|
||||
Decrease connection->n_incoming when removing an entry
|
||||
from the list.
|
||||
* dbus/dbus-dict.c: (dbus_dict_entry_free),
|
||||
(dbus_dict_set_boolean_array), (dbus_dict_set_int32_array),
|
||||
(dbus_dict_set_uint32_array), (dbus_dict_set_double_array),
|
||||
(dbus_dict_set_byte_array), (dbus_dict_set_string_array),
|
||||
(dbus_dict_get_boolean_array), (dbus_dict_get_double_array),
|
||||
(dbus_dict_get_byte_array):
|
||||
Handle NULL arrays and strings. Also add support for byte arrays.
|
||||
|
||||
* dbus/dbus-marshal.c: (_dbus_marshal_byte_array),
|
||||
(_dbus_marshal_dict), (_dbus_demarshal_byte_array),
|
||||
(_dbus_demarshal_int32_array), (_dbus_demarshal_uint32_array),
|
||||
(_dbus_demarshal_double_array), (_dbus_demarshal_string_array),
|
||||
(_dbus_demarshal_dict), (demarshal_and_validate_len),
|
||||
(_dbus_marshal_validate_arg), (_dbus_marshal_test):
|
||||
* dbus/dbus-marshal.h:
|
||||
Add support for marshalling and demarshalling empty arrays and strings.
|
||||
|
||||
* dbus/dbus-message.c: (dbus_message_append_args_valist),
|
||||
(dbus_message_append_string_array),
|
||||
(dbus_message_iter_get_boolean),
|
||||
(dbus_message_iter_get_boolean_array),
|
||||
(dbus_message_iter_get_int32_array),
|
||||
(dbus_message_iter_get_uint32_array),
|
||||
(dbus_message_iter_get_double_array),
|
||||
(dbus_message_iter_get_byte_array),
|
||||
(dbus_message_iter_get_string_array), (dbus_message_iter_get_dict),
|
||||
(check_message_handling):
|
||||
Add support for getting empty arrays and dicts.
|
||||
|
||||
* dbus/dbus-string.c: (_dbus_string_validate_utf8):
|
||||
Don't do any validation at all for now, that's better than just checking
|
||||
for ASCII.
|
||||
|
||||
* test/data/valid-messages/emptiness.message:
|
||||
New test message with lots of empty arrays.
|
||||
|
||||
2003-03-16 Havoc Pennington <hp@pobox.com>
|
||||
|
||||
* dbus/dbus-connection.c
|
||||
|
|
|
|||
|
|
@ -1443,6 +1443,7 @@ dbus_connection_send_with_reply_and_block (DBusConnection *connection,
|
|||
if (dbus_message_get_reply_serial (reply) == client_serial)
|
||||
{
|
||||
_dbus_list_remove_link (&connection->incoming_messages, link);
|
||||
connection->n_incoming -= 1;
|
||||
dbus_message_ref (reply);
|
||||
|
||||
dbus_mutex_unlock (connection->mutex);
|
||||
|
|
|
|||
128
dbus/dbus-dict.c
128
dbus/dbus-dict.c
|
|
@ -55,7 +55,7 @@ typedef struct
|
|||
struct {
|
||||
unsigned char *value;
|
||||
int len;
|
||||
} boolean_array;
|
||||
} byte_array;
|
||||
struct {
|
||||
dbus_int32_t *value;
|
||||
int len;
|
||||
|
|
@ -92,8 +92,9 @@ dbus_dict_entry_free (DBusDictEntry *entry)
|
|||
case DBUS_TYPE_STRING:
|
||||
dbus_free (entry->v.string_value);
|
||||
break;
|
||||
case DBUS_TYPE_BYTE_ARRAY:
|
||||
case DBUS_TYPE_BOOLEAN_ARRAY:
|
||||
dbus_free (entry->v.boolean_array.value);
|
||||
dbus_free (entry->v.byte_array.value);
|
||||
break;
|
||||
case DBUS_TYPE_INT32_ARRAY:
|
||||
dbus_free (entry->v.int32_array.value);
|
||||
|
|
@ -473,18 +474,23 @@ dbus_dict_set_boolean_array (DBusDict *dict,
|
|||
DBusDictEntry *entry;
|
||||
unsigned char *tmp;
|
||||
|
||||
tmp = dbus_malloc (len);
|
||||
|
||||
if (!tmp)
|
||||
return FALSE;
|
||||
if (len == 0)
|
||||
tmp = NULL;
|
||||
else
|
||||
{
|
||||
tmp = dbus_malloc (len);
|
||||
|
||||
if (!tmp)
|
||||
return FALSE;
|
||||
|
||||
memcpy (tmp, value, len);
|
||||
memcpy (tmp, value, len);
|
||||
}
|
||||
|
||||
if (insert_entry (dict, key, &entry))
|
||||
{
|
||||
entry->type = DBUS_TYPE_BOOLEAN_ARRAY;
|
||||
entry->v.boolean_array.value = tmp;
|
||||
entry->v.boolean_array.len = len;
|
||||
entry->v.byte_array.value = tmp;
|
||||
entry->v.byte_array.len = len;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -511,11 +517,16 @@ dbus_dict_set_int32_array (DBusDict *dict,
|
|||
DBusDictEntry *entry;
|
||||
dbus_int32_t *tmp;
|
||||
|
||||
tmp = dbus_new (dbus_int32_t, len);
|
||||
|
||||
if (!tmp)
|
||||
return FALSE;
|
||||
|
||||
if (len == 0)
|
||||
tmp = NULL;
|
||||
else
|
||||
{
|
||||
tmp = dbus_new (dbus_int32_t, len);
|
||||
|
||||
if (!tmp)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
memcpy (tmp, value, len * sizeof (dbus_int32_t));
|
||||
|
||||
if (insert_entry (dict, key, &entry))
|
||||
|
|
@ -550,12 +561,17 @@ dbus_dict_set_uint32_array (DBusDict *dict,
|
|||
DBusDictEntry *entry;
|
||||
dbus_uint32_t *tmp;
|
||||
|
||||
tmp = dbus_new (dbus_uint32_t, len);
|
||||
|
||||
if (!tmp)
|
||||
return FALSE;
|
||||
|
||||
memcpy (tmp, value, len * sizeof (dbus_uint32_t));
|
||||
if (len == 0)
|
||||
tmp = NULL;
|
||||
else
|
||||
{
|
||||
tmp = dbus_new (dbus_uint32_t, len);
|
||||
|
||||
if (!tmp)
|
||||
return FALSE;
|
||||
|
||||
memcpy (tmp, value, len * sizeof (dbus_uint32_t));
|
||||
}
|
||||
|
||||
if (insert_entry (dict, key, &entry))
|
||||
{
|
||||
|
|
@ -588,12 +604,17 @@ dbus_dict_set_double_array (DBusDict *dict,
|
|||
DBusDictEntry *entry;
|
||||
double *tmp;
|
||||
|
||||
tmp = dbus_new (double, len);
|
||||
if (len == 0)
|
||||
tmp = NULL;
|
||||
else
|
||||
{
|
||||
tmp = dbus_new (double, len);
|
||||
|
||||
if (!tmp)
|
||||
return FALSE;
|
||||
if (!tmp)
|
||||
return FALSE;
|
||||
|
||||
memcpy (tmp, value, len * sizeof (double));
|
||||
memcpy (tmp, value, len * sizeof (double));
|
||||
}
|
||||
|
||||
if (insert_entry (dict, key, &entry))
|
||||
{
|
||||
|
|
@ -607,6 +628,40 @@ dbus_dict_set_double_array (DBusDict *dict,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
dbus_bool_t
|
||||
dbus_dict_set_byte_array (DBusDict *dict,
|
||||
const char *key,
|
||||
unsigned const char *value,
|
||||
int len)
|
||||
{
|
||||
DBusDictEntry *entry;
|
||||
unsigned char *tmp;
|
||||
|
||||
if (len == 0)
|
||||
tmp = NULL;
|
||||
else
|
||||
{
|
||||
tmp = dbus_malloc (len);
|
||||
|
||||
if (!tmp)
|
||||
return FALSE;
|
||||
|
||||
memcpy (tmp, value, len);
|
||||
}
|
||||
|
||||
if (insert_entry (dict, key, &entry))
|
||||
{
|
||||
entry->type = DBUS_TYPE_BYTE_ARRAY;
|
||||
entry->v.byte_array.value = tmp;
|
||||
entry->v.byte_array.len = len;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds a string array to the dict. If a value with the same key
|
||||
* already exists, then it will be replaced by the new value.
|
||||
|
|
@ -631,6 +686,8 @@ dbus_dict_set_string_array (DBusDict *dict,
|
|||
if (!tmp)
|
||||
return FALSE;
|
||||
|
||||
tmp[len] = NULL;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
tmp[i] = _dbus_strdup (value[i]);
|
||||
|
|
@ -806,8 +863,8 @@ dbus_dict_get_boolean_array (DBusDict *dict,
|
|||
if (!entry || entry->type != DBUS_TYPE_BOOLEAN_ARRAY)
|
||||
return FALSE;
|
||||
|
||||
*value = entry->v.boolean_array.value;
|
||||
*len = entry->v.boolean_array.len;
|
||||
*value = entry->v.byte_array.value;
|
||||
*len = entry->v.byte_array.len;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -899,6 +956,25 @@ dbus_dict_get_double_array (DBusDict *dict,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
dbus_bool_t
|
||||
dbus_dict_get_byte_array (DBusDict *dict,
|
||||
const char *key,
|
||||
unsigned const char **value,
|
||||
int *len)
|
||||
{
|
||||
DBusDictEntry *entry;
|
||||
|
||||
entry = _dbus_hash_table_lookup_string (dict->table, key);
|
||||
|
||||
if (!entry || entry->type != DBUS_TYPE_BYTE_ARRAY)
|
||||
return FALSE;
|
||||
|
||||
*value = entry->v.byte_array.value;
|
||||
*len = entry->v.byte_array.len;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a string array from a dict using a key.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -352,7 +352,10 @@ _dbus_marshal_byte_array (DBusString *str,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
return _dbus_string_append_len (str, value, len);
|
||||
if (len == 0)
|
||||
return TRUE;
|
||||
else
|
||||
return _dbus_string_append_len (str, value, len);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -521,7 +524,7 @@ _dbus_marshal_dict (DBusString *str,
|
|||
return TRUE;
|
||||
|
||||
if (!_dbus_marshal_string_array (str, byte_order,
|
||||
keys, len))
|
||||
(const char **)keys, len))
|
||||
goto error;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
|
|
@ -656,13 +659,13 @@ _dbus_marshal_dict (DBusString *str,
|
|||
if (!dbus_dict_get_string_array (dict, keys[i], &value, &len))
|
||||
goto error;
|
||||
|
||||
if (!_dbus_marshal_string_array (str, byte_order, value, len))
|
||||
if (!_dbus_marshal_string_array (str, byte_order, (const char **)value, len))
|
||||
goto error;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
_dbus_warn ("unknwon value type %d\n", dbus_dict_get_value_type (dict, keys[i]));
|
||||
_dbus_warn ("unkown value type %d\n", dbus_dict_get_value_type (dict, keys[i]));
|
||||
_dbus_assert_not_reached ("unknown value type in dict");
|
||||
}
|
||||
}
|
||||
|
|
@ -826,16 +829,18 @@ _dbus_demarshal_string (const DBusString *str,
|
|||
* @param str the string containing the data
|
||||
* @param byte_order the byte order
|
||||
* @param pos the position in the string
|
||||
* @param new_pos the new position of the string
|
||||
* @param array the array
|
||||
* @param array_len length of the demarshaled data
|
||||
* @returns the demarshaled data.
|
||||
|
||||
* @returns #TRUE on success
|
||||
*/
|
||||
unsigned char *
|
||||
_dbus_demarshal_byte_array (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos,
|
||||
int *array_len)
|
||||
dbus_bool_t
|
||||
_dbus_demarshal_byte_array (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos,
|
||||
unsigned char **array,
|
||||
int *array_len)
|
||||
{
|
||||
int len;
|
||||
unsigned char *retval;
|
||||
|
|
@ -843,25 +848,39 @@ _dbus_demarshal_byte_array (const DBusString *str,
|
|||
|
||||
len = _dbus_demarshal_uint32 (str, byte_order, pos, &pos);
|
||||
|
||||
if (len == 0)
|
||||
{
|
||||
*array_len = len;
|
||||
*array = NULL;
|
||||
|
||||
if (new_pos)
|
||||
*new_pos = pos;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
retval = dbus_malloc (len);
|
||||
|
||||
if (!retval)
|
||||
return NULL;
|
||||
return FALSE;
|
||||
|
||||
_dbus_string_get_const_data_len (str, &data, pos, len);
|
||||
|
||||
if (!data)
|
||||
return NULL;
|
||||
{
|
||||
dbus_free (retval);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
memcpy (retval, data, len);
|
||||
|
||||
if (new_pos)
|
||||
*new_pos = pos + len;
|
||||
|
||||
if (array_len)
|
||||
*array_len = len;
|
||||
|
||||
return retval;
|
||||
*array = retval;
|
||||
*array_len = len;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -871,25 +890,38 @@ _dbus_demarshal_byte_array (const DBusString *str,
|
|||
* @param byte_order the byte order
|
||||
* @param pos the position in the string
|
||||
* @param new_pos the new position of the string
|
||||
* @param array the array
|
||||
* @param array_len length of the demarshaled data
|
||||
* @returns the demarshaled data.
|
||||
* @returns #TRUE on success
|
||||
*/
|
||||
dbus_int32_t *
|
||||
_dbus_demarshal_int32_array (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos,
|
||||
int *array_len)
|
||||
dbus_bool_t
|
||||
_dbus_demarshal_int32_array (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos,
|
||||
dbus_int32_t **array,
|
||||
int *array_len)
|
||||
{
|
||||
int len, i;
|
||||
dbus_int32_t *retval;
|
||||
|
||||
len = _dbus_demarshal_uint32 (str, byte_order, pos, &pos);
|
||||
|
||||
retval = dbus_new (dbus_int32_t, len);
|
||||
if (len == 0)
|
||||
{
|
||||
*array_len = 0;
|
||||
*array = NULL;
|
||||
|
||||
if (new_pos)
|
||||
*new_pos = pos;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
retval = dbus_new (dbus_int32_t, len);
|
||||
|
||||
if (!retval)
|
||||
return NULL;
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
retval[i] = _dbus_demarshal_int32 (str, byte_order, pos, &pos);
|
||||
|
|
@ -897,10 +929,10 @@ _dbus_demarshal_int32_array (const DBusString *str,
|
|||
if (new_pos)
|
||||
*new_pos = pos;
|
||||
|
||||
if (array_len)
|
||||
*array_len = len;
|
||||
*array_len = len;
|
||||
*array = retval;
|
||||
|
||||
return retval;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -910,25 +942,38 @@ _dbus_demarshal_int32_array (const DBusString *str,
|
|||
* @param byte_order the byte order
|
||||
* @param pos the position in the string
|
||||
* @param new_pos the new position of the string
|
||||
* @param array the array
|
||||
* @param array_len length of the demarshaled data
|
||||
* @returns the demarshaled data.
|
||||
* @returns #TRUE on success
|
||||
*/
|
||||
dbus_uint32_t *
|
||||
_dbus_demarshal_uint32_array (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos,
|
||||
int *array_len)
|
||||
dbus_bool_t
|
||||
_dbus_demarshal_uint32_array (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos,
|
||||
dbus_uint32_t **array,
|
||||
int *array_len)
|
||||
{
|
||||
int len, i;
|
||||
dbus_uint32_t *retval;
|
||||
|
||||
len = _dbus_demarshal_uint32 (str, byte_order, pos, &pos);
|
||||
|
||||
if (len == 0)
|
||||
{
|
||||
*array_len = 0;
|
||||
*array = NULL;
|
||||
|
||||
if (new_pos)
|
||||
*new_pos = pos;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
retval = dbus_new (dbus_uint32_t, len);
|
||||
|
||||
if (!retval)
|
||||
return NULL;
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
retval[i] = _dbus_demarshal_uint32 (str, byte_order, pos, &pos);
|
||||
|
|
@ -936,10 +981,10 @@ _dbus_demarshal_uint32_array (const DBusString *str,
|
|||
if (new_pos)
|
||||
*new_pos = pos;
|
||||
|
||||
if (array_len)
|
||||
*array_len = len;
|
||||
*array_len = len;
|
||||
*array = retval;
|
||||
|
||||
return retval;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -949,25 +994,38 @@ _dbus_demarshal_uint32_array (const DBusString *str,
|
|||
* @param byte_order the byte order
|
||||
* @param pos the position in the string
|
||||
* @param new_pos the new position of the string
|
||||
* @param array the array
|
||||
* @param array_len length of the demarshaled data
|
||||
* @returns the demarshaled data.
|
||||
* @returns #TRUE on success
|
||||
*/
|
||||
double *
|
||||
_dbus_demarshal_double_array (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos,
|
||||
int *array_len)
|
||||
dbus_bool_t
|
||||
_dbus_demarshal_double_array (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos,
|
||||
double **array,
|
||||
int *array_len)
|
||||
{
|
||||
int len, i;
|
||||
double *retval;
|
||||
|
||||
len = _dbus_demarshal_uint32 (str, byte_order, pos, &pos);
|
||||
|
||||
if (len == 0)
|
||||
{
|
||||
*array_len = 0;
|
||||
*array = NULL;
|
||||
|
||||
if (new_pos)
|
||||
*new_pos = pos;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
retval = dbus_new (double, len);
|
||||
|
||||
if (!retval)
|
||||
return NULL;
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
retval[i] = _dbus_demarshal_double (str, byte_order, pos, &pos);
|
||||
|
|
@ -975,10 +1033,10 @@ _dbus_demarshal_double_array (const DBusString *str,
|
|||
if (new_pos)
|
||||
*new_pos = pos;
|
||||
|
||||
if (array_len)
|
||||
*array_len = len;
|
||||
*array_len = len;
|
||||
*array = retval;
|
||||
|
||||
return retval;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -988,25 +1046,38 @@ _dbus_demarshal_double_array (const DBusString *str,
|
|||
* @param byte_order the byte order
|
||||
* @param pos the position in the string
|
||||
* @param new_pos the new position of the string
|
||||
* @param array the array
|
||||
* @param array_len length of the demarshaled data
|
||||
* @returns the demarshaled data.
|
||||
* @returns #TRUE on success
|
||||
*/
|
||||
char **
|
||||
_dbus_demarshal_string_array (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos,
|
||||
int *array_len)
|
||||
dbus_bool_t
|
||||
_dbus_demarshal_string_array (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos,
|
||||
char ***array,
|
||||
int *array_len)
|
||||
{
|
||||
int len, i, j;
|
||||
char **retval;
|
||||
|
||||
len = _dbus_demarshal_uint32 (str, byte_order, pos, &pos);
|
||||
|
||||
if (len == 0)
|
||||
{
|
||||
*array_len = 0;
|
||||
*array = NULL;
|
||||
|
||||
if (new_pos)
|
||||
*new_pos = pos;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
retval = dbus_new (char *, len + 1);
|
||||
|
||||
if (!retval)
|
||||
return NULL;
|
||||
return FALSE;
|
||||
|
||||
retval[len] = NULL;
|
||||
|
||||
|
|
@ -1021,17 +1092,17 @@ _dbus_demarshal_string_array (const DBusString *str,
|
|||
if (new_pos)
|
||||
*new_pos = pos;
|
||||
|
||||
if (array_len)
|
||||
*array_len = len;
|
||||
*array = retval;
|
||||
*array_len = len;
|
||||
|
||||
return retval;
|
||||
return TRUE;
|
||||
|
||||
error:
|
||||
for (j = 0; j < i; j++)
|
||||
dbus_free (retval[i]);
|
||||
dbus_free (retval);
|
||||
|
||||
return NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1041,25 +1112,24 @@ _dbus_demarshal_string_array (const DBusString *str,
|
|||
* @param byte_order the byte order
|
||||
* @param pos the position in the string
|
||||
* @param new_pos the new position in the string
|
||||
* @returns the demarshalled dict
|
||||
* @param dict the dict
|
||||
* @returns #TRUE on success.
|
||||
*/
|
||||
DBusDict *
|
||||
dbus_bool_t
|
||||
_dbus_demarshal_dict (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos)
|
||||
int *new_pos,
|
||||
DBusDict **dict)
|
||||
{
|
||||
char **keys;
|
||||
int i, len;
|
||||
DBusDict *dict;
|
||||
|
||||
dict = dbus_dict_new ();
|
||||
if (!dict)
|
||||
return NULL;
|
||||
*dict = dbus_dict_new ();
|
||||
if (!*dict)
|
||||
return FALSE;
|
||||
|
||||
keys = _dbus_demarshal_string_array (str, byte_order, pos, &pos, &len);
|
||||
|
||||
if (!keys)
|
||||
if (!_dbus_demarshal_string_array (str, byte_order, pos, &pos, &keys, &len))
|
||||
goto error;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
|
|
@ -1074,7 +1144,7 @@ _dbus_demarshal_dict (const DBusString *str,
|
|||
|
||||
value = _dbus_string_get_byte (str, pos ++);
|
||||
|
||||
if (!dbus_dict_set_boolean (dict, keys[i], value))
|
||||
if (!dbus_dict_set_boolean (*dict, keys[i], value))
|
||||
goto error;
|
||||
break;
|
||||
}
|
||||
|
|
@ -1084,7 +1154,7 @@ _dbus_demarshal_dict (const DBusString *str,
|
|||
|
||||
value = _dbus_demarshal_int32 (str, byte_order, pos, &pos);
|
||||
|
||||
if (!dbus_dict_set_int32 (dict, keys[i], value))
|
||||
if (!dbus_dict_set_int32 (*dict, keys[i], value))
|
||||
goto error;
|
||||
|
||||
break;
|
||||
|
|
@ -1095,7 +1165,7 @@ _dbus_demarshal_dict (const DBusString *str,
|
|||
|
||||
value = _dbus_demarshal_uint32 (str, byte_order, pos, &pos);
|
||||
|
||||
if (!dbus_dict_set_uint32 (dict, keys[i], value))
|
||||
if (!dbus_dict_set_uint32 (*dict, keys[i], value))
|
||||
goto error;
|
||||
|
||||
break;
|
||||
|
|
@ -1106,7 +1176,7 @@ _dbus_demarshal_dict (const DBusString *str,
|
|||
|
||||
value = _dbus_demarshal_double (str, byte_order, pos, &pos);
|
||||
|
||||
if (!dbus_dict_set_double (dict, keys[i], value))
|
||||
if (!dbus_dict_set_double (*dict, keys[i], value))
|
||||
goto error;
|
||||
|
||||
break;
|
||||
|
|
@ -1120,7 +1190,7 @@ _dbus_demarshal_dict (const DBusString *str,
|
|||
if (!value)
|
||||
goto error;
|
||||
|
||||
if (!dbus_dict_set_string (dict, keys[i], value))
|
||||
if (!dbus_dict_set_string (*dict, keys[i], value))
|
||||
{
|
||||
dbus_free (value);
|
||||
goto error;
|
||||
|
|
@ -1135,12 +1205,10 @@ _dbus_demarshal_dict (const DBusString *str,
|
|||
unsigned char *value;
|
||||
int len;
|
||||
|
||||
value = _dbus_demarshal_byte_array (str, byte_order, pos, &pos, &len);
|
||||
|
||||
if (!value)
|
||||
if (!_dbus_demarshal_byte_array (str, byte_order, pos, &pos, &value, &len))
|
||||
goto error;
|
||||
|
||||
if (!dbus_dict_set_boolean_array (dict, keys[i], value, len))
|
||||
if (!dbus_dict_set_boolean_array (*dict, keys[i], value, len))
|
||||
{
|
||||
dbus_free (value);
|
||||
goto error;
|
||||
|
|
@ -1154,12 +1222,10 @@ _dbus_demarshal_dict (const DBusString *str,
|
|||
dbus_int32_t *value;
|
||||
int len;
|
||||
|
||||
value = _dbus_demarshal_int32_array (str, byte_order, pos, &pos, &len);
|
||||
|
||||
if (!value)
|
||||
if (!_dbus_demarshal_int32_array (str, byte_order, pos, &pos, &value, &len))
|
||||
goto error;
|
||||
|
||||
if (!dbus_dict_set_int32_array (dict, keys[i], value, len))
|
||||
if (!dbus_dict_set_int32_array (*dict, keys[i], value, len))
|
||||
{
|
||||
dbus_free (value);
|
||||
goto error;
|
||||
|
|
@ -1173,12 +1239,10 @@ _dbus_demarshal_dict (const DBusString *str,
|
|||
dbus_uint32_t *value;
|
||||
int len;
|
||||
|
||||
value = _dbus_demarshal_uint32_array (str, byte_order, pos, &pos, &len);
|
||||
|
||||
if (!value)
|
||||
if (!_dbus_demarshal_uint32_array (str, byte_order, pos, &pos, &value, &len))
|
||||
goto error;
|
||||
|
||||
if (!dbus_dict_set_uint32_array (dict, keys[i], value, len))
|
||||
if (!dbus_dict_set_uint32_array (*dict, keys[i], value, len))
|
||||
{
|
||||
dbus_free (value);
|
||||
goto error;
|
||||
|
|
@ -1192,12 +1256,27 @@ _dbus_demarshal_dict (const DBusString *str,
|
|||
double *value;
|
||||
int len;
|
||||
|
||||
value = _dbus_demarshal_double_array (str, byte_order, pos, &pos, &len);
|
||||
|
||||
if (!value)
|
||||
if (!_dbus_demarshal_double_array (str, byte_order, pos, &pos, &value, &len))
|
||||
goto error;
|
||||
|
||||
if (!dbus_dict_set_double_array (dict, keys[i], value, len))
|
||||
if (!dbus_dict_set_double_array (*dict, keys[i], value, len))
|
||||
{
|
||||
dbus_free (value);
|
||||
goto error;
|
||||
}
|
||||
|
||||
dbus_free (value);
|
||||
break;
|
||||
}
|
||||
case DBUS_TYPE_BYTE_ARRAY:
|
||||
{
|
||||
unsigned char *value;
|
||||
int len;
|
||||
|
||||
if (!_dbus_demarshal_byte_array (str, byte_order, pos, &pos, &value, &len))
|
||||
goto error;
|
||||
|
||||
if (!dbus_dict_set_byte_array (*dict, keys[i], value, len))
|
||||
{
|
||||
dbus_free (value);
|
||||
goto error;
|
||||
|
|
@ -1211,12 +1290,10 @@ _dbus_demarshal_dict (const DBusString *str,
|
|||
char **value;
|
||||
int len;
|
||||
|
||||
value = _dbus_demarshal_string_array (str, byte_order, pos, &pos, &len);
|
||||
|
||||
if (!value)
|
||||
if (!_dbus_demarshal_string_array (str, byte_order, pos, &pos, &value, &len))
|
||||
goto error;
|
||||
|
||||
if (!dbus_dict_set_string_array (dict, keys[i], value, len))
|
||||
if (!dbus_dict_set_string_array (*dict, keys[i], (const char **)value, len))
|
||||
{
|
||||
dbus_free_string_array (value);
|
||||
goto error;
|
||||
|
|
@ -1232,12 +1309,13 @@ _dbus_demarshal_dict (const DBusString *str,
|
|||
}
|
||||
|
||||
dbus_free_string_array (keys);
|
||||
return dict;
|
||||
return TRUE;
|
||||
|
||||
error:
|
||||
dbus_free_string_array (keys);
|
||||
dbus_dict_unref (dict);
|
||||
return NULL;
|
||||
dbus_dict_unref (*dict);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1436,7 +1514,7 @@ demarshal_and_validate_len (const DBusString *str,
|
|||
|
||||
_dbus_assert (new_pos != NULL);
|
||||
|
||||
if ((align_4 + 4) >= _dbus_string_get_length (str))
|
||||
if ((align_4 + 4) > _dbus_string_get_length (str))
|
||||
{
|
||||
_dbus_verbose ("not enough room in message for array length\n");
|
||||
return -1;
|
||||
|
|
@ -1671,15 +1749,20 @@ _dbus_marshal_validate_arg (const DBusString *str,
|
|||
if (len < 0)
|
||||
return FALSE;
|
||||
|
||||
align_8 = _DBUS_ALIGN_VALUE (pos, 8);
|
||||
if (!_dbus_string_validate_nul (str, pos,
|
||||
align_8 - pos))
|
||||
{
|
||||
_dbus_verbose ("double array alignment padding not initialized to nul\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*end_pos = align_8 + len * 8;
|
||||
if (len == 0)
|
||||
*end_pos = pos;
|
||||
else
|
||||
{
|
||||
align_8 = _DBUS_ALIGN_VALUE (pos, 8);
|
||||
if (!_dbus_string_validate_nul (str, pos,
|
||||
align_8 - pos))
|
||||
{
|
||||
_dbus_verbose ("double array alignment padding not initialized to nul\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*end_pos = align_8 + len * 8;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -1965,7 +2048,8 @@ _dbus_marshal_test (void)
|
|||
/* Marshal signed integer arrays */
|
||||
if (!_dbus_marshal_int32_array (&str, DBUS_BIG_ENDIAN, array1, 3))
|
||||
_dbus_assert_not_reached ("could not marshal integer array");
|
||||
array2 = _dbus_demarshal_int32_array (&str, DBUS_BIG_ENDIAN, pos, &pos, &len);
|
||||
if (!_dbus_demarshal_int32_array (&str, DBUS_BIG_ENDIAN, pos, &pos, &array2, &len))
|
||||
_dbus_assert_not_reached ("could not demarshal integer array");
|
||||
|
||||
if (len != 3)
|
||||
_dbus_assert_not_reached ("Signed integer array lengths differ!\n");
|
||||
|
|
@ -2013,7 +2097,8 @@ _dbus_marshal_test (void)
|
|||
|
||||
dbus_dict_unref (dict);
|
||||
|
||||
dict = _dbus_demarshal_dict (&str, DBUS_BIG_ENDIAN, pos, &pos);
|
||||
if (!_dbus_demarshal_dict (&str, DBUS_BIG_ENDIAN, pos, &pos, &dict))
|
||||
_dbus_assert_not_reached ("could not demarshal dict");
|
||||
|
||||
if (!dbus_dict_get_boolean (dict, "boolean", &our_bool) ||
|
||||
!our_bool)
|
||||
|
|
|
|||
|
|
@ -92,88 +92,93 @@ dbus_bool_t _dbus_marshal_set_string (DBusString *str,
|
|||
const DBusString *value,
|
||||
int len);
|
||||
|
||||
dbus_bool_t _dbus_marshal_int32 (DBusString *str,
|
||||
int byte_order,
|
||||
dbus_int32_t value);
|
||||
dbus_bool_t _dbus_marshal_uint32 (DBusString *str,
|
||||
int byte_order,
|
||||
dbus_uint32_t value);
|
||||
dbus_bool_t _dbus_marshal_double (DBusString *str,
|
||||
int byte_order,
|
||||
double value);
|
||||
dbus_bool_t _dbus_marshal_string (DBusString *str,
|
||||
int byte_order,
|
||||
const char *value);
|
||||
dbus_bool_t _dbus_marshal_byte_array (DBusString *str,
|
||||
int byte_order,
|
||||
const unsigned char *value,
|
||||
int len);
|
||||
dbus_bool_t _dbus_marshal_int32_array (DBusString *str,
|
||||
int byte_order,
|
||||
const dbus_int32_t *value,
|
||||
int len);
|
||||
dbus_bool_t _dbus_marshal_uint32_array (DBusString *str,
|
||||
int byte_order,
|
||||
const dbus_uint32_t *value,
|
||||
int len);
|
||||
dbus_bool_t _dbus_marshal_double_array (DBusString *str,
|
||||
int byte_order,
|
||||
const double *value,
|
||||
int len);
|
||||
dbus_bool_t _dbus_marshal_string_array (DBusString *str,
|
||||
int byte_order,
|
||||
const char **value,
|
||||
int len);
|
||||
dbus_bool_t _dbus_marshal_dict (DBusString *str,
|
||||
int byte_order,
|
||||
DBusDict *dict);
|
||||
double _dbus_demarshal_double (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos);
|
||||
dbus_int32_t _dbus_demarshal_int32 (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos);
|
||||
dbus_uint32_t _dbus_demarshal_uint32 (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos);
|
||||
char * _dbus_demarshal_string (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos);
|
||||
dbus_bool_t _dbus_demarshal_byte_array (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos,
|
||||
unsigned char **array,
|
||||
int *array_len);
|
||||
dbus_bool_t _dbus_demarshal_int32_array (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos,
|
||||
dbus_int32_t **array,
|
||||
int *array_len);
|
||||
dbus_bool_t _dbus_demarshal_uint32_array (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos,
|
||||
dbus_uint32_t **array,
|
||||
int *array_len);
|
||||
dbus_bool_t _dbus_demarshal_double_array (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos,
|
||||
double **array,
|
||||
int *array_len);
|
||||
dbus_bool_t _dbus_demarshal_string_array (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos,
|
||||
char ***array,
|
||||
int *array_len);
|
||||
dbus_bool_t _dbus_demarshal_dict (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos,
|
||||
DBusDict **dict);
|
||||
|
||||
dbus_bool_t _dbus_marshal_int32 (DBusString *str,
|
||||
int byte_order,
|
||||
dbus_int32_t value);
|
||||
dbus_bool_t _dbus_marshal_uint32 (DBusString *str,
|
||||
int byte_order,
|
||||
dbus_uint32_t value);
|
||||
dbus_bool_t _dbus_marshal_double (DBusString *str,
|
||||
int byte_order,
|
||||
double value);
|
||||
dbus_bool_t _dbus_marshal_string (DBusString *str,
|
||||
int byte_order,
|
||||
const char *value);
|
||||
dbus_bool_t _dbus_marshal_byte_array (DBusString *str,
|
||||
int byte_order,
|
||||
const unsigned char *value,
|
||||
int len);
|
||||
dbus_bool_t _dbus_marshal_int32_array (DBusString *str,
|
||||
int byte_order,
|
||||
const dbus_int32_t *value,
|
||||
int len);
|
||||
dbus_bool_t _dbus_marshal_uint32_array (DBusString *str,
|
||||
int byte_order,
|
||||
const dbus_uint32_t *value,
|
||||
int len);
|
||||
dbus_bool_t _dbus_marshal_double_array (DBusString *str,
|
||||
int byte_order,
|
||||
const double *value,
|
||||
int len);
|
||||
dbus_bool_t _dbus_marshal_string_array (DBusString *str,
|
||||
int byte_order,
|
||||
const char **value,
|
||||
int len);
|
||||
dbus_bool_t _dbus_marshal_dict (DBusString *str,
|
||||
int byte_order,
|
||||
DBusDict *dict);
|
||||
|
||||
double _dbus_demarshal_double (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos);
|
||||
dbus_int32_t _dbus_demarshal_int32 (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos);
|
||||
dbus_uint32_t _dbus_demarshal_uint32 (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos);
|
||||
char * _dbus_demarshal_string (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos);
|
||||
unsigned char *_dbus_demarshal_byte_array (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos,
|
||||
int *array_len);
|
||||
dbus_int32_t * _dbus_demarshal_int32_array (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos,
|
||||
int *array_len);
|
||||
dbus_uint32_t *_dbus_demarshal_uint32_array (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos,
|
||||
int *array_len);
|
||||
double * _dbus_demarshal_double_array (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos,
|
||||
int *array_len);
|
||||
char ** _dbus_demarshal_string_array (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos,
|
||||
int *array_len);
|
||||
DBusDict * _dbus_demarshal_dict (const DBusString *str,
|
||||
int byte_order,
|
||||
int pos,
|
||||
int *new_pos);
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1167,7 +1167,7 @@ dbus_message_append_args_valist (DBusMessage *message,
|
|||
case DBUS_TYPE_STRING_ARRAY:
|
||||
{
|
||||
int len;
|
||||
const char **data;
|
||||
char **data;
|
||||
|
||||
data = va_arg (var_args, const char **);
|
||||
len = va_arg (var_args, int);
|
||||
|
|
@ -1184,6 +1184,7 @@ dbus_message_append_args_valist (DBusMessage *message,
|
|||
|
||||
if (!dbus_message_append_dict (message, dict))
|
||||
goto enomem;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
_dbus_warn ("Unknown field type %d\n", type);
|
||||
|
|
@ -1487,9 +1488,9 @@ dbus_message_append_byte_array (DBusMessage *message,
|
|||
* @returns #TRUE on success
|
||||
*/
|
||||
dbus_bool_t
|
||||
dbus_message_append_string_array (DBusMessage *message,
|
||||
const char **value,
|
||||
int len)
|
||||
dbus_message_append_string_array (DBusMessage *message,
|
||||
const char **value,
|
||||
int len)
|
||||
{
|
||||
_dbus_assert (!message->locked);
|
||||
|
||||
|
|
@ -1497,7 +1498,7 @@ dbus_message_append_string_array (DBusMessage *message,
|
|||
return FALSE;
|
||||
|
||||
if (!_dbus_marshal_string_array (&message->body, message->byte_order,
|
||||
value, len))
|
||||
(const char **)value, len))
|
||||
{
|
||||
_dbus_string_shorten (&message->body, 1);
|
||||
return FALSE;
|
||||
|
|
@ -1991,7 +1992,6 @@ dbus_message_iter_get_boolean (DBusMessageIter *iter)
|
|||
_dbus_assert (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_BOOLEAN);
|
||||
|
||||
value = _dbus_string_get_byte (&iter->message->body, iter->pos + 1);
|
||||
iter->pos += 2;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
|
@ -2067,10 +2067,8 @@ dbus_message_iter_get_boolean_array (DBusMessageIter *iter,
|
|||
{
|
||||
_dbus_assert (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_BOOLEAN_ARRAY);
|
||||
|
||||
*value = _dbus_demarshal_byte_array (&iter->message->body, iter->message->byte_order,
|
||||
iter->pos + 1, NULL, len);
|
||||
|
||||
if (!*value)
|
||||
if (!_dbus_demarshal_byte_array (&iter->message->body, iter->message->byte_order,
|
||||
iter->pos + 1, NULL, value, len))
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
|
|
@ -2093,10 +2091,8 @@ dbus_message_iter_get_int32_array (DBusMessageIter *iter,
|
|||
{
|
||||
_dbus_assert (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_INT32_ARRAY);
|
||||
|
||||
*value = _dbus_demarshal_int32_array (&iter->message->body, iter->message->byte_order,
|
||||
iter->pos + 1, NULL, len);
|
||||
|
||||
if (!*value)
|
||||
if (!_dbus_demarshal_int32_array (&iter->message->body, iter->message->byte_order,
|
||||
iter->pos + 1, NULL, value, len))
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
|
|
@ -2119,10 +2115,8 @@ dbus_message_iter_get_uint32_array (DBusMessageIter *iter,
|
|||
{
|
||||
_dbus_assert (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_UINT32_ARRAY);
|
||||
|
||||
*value = _dbus_demarshal_uint32_array (&iter->message->body, iter->message->byte_order,
|
||||
iter->pos + 1, NULL, len);
|
||||
|
||||
if (!*value)
|
||||
if (!_dbus_demarshal_uint32_array (&iter->message->body, iter->message->byte_order,
|
||||
iter->pos + 1, NULL, value, len))
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
|
|
@ -2145,10 +2139,8 @@ dbus_message_iter_get_double_array (DBusMessageIter *iter,
|
|||
{
|
||||
_dbus_assert (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_DOUBLE_ARRAY);
|
||||
|
||||
*value = _dbus_demarshal_double_array (&iter->message->body, iter->message->byte_order,
|
||||
iter->pos + 1, NULL, len);
|
||||
|
||||
if (!*value)
|
||||
if (!_dbus_demarshal_double_array (&iter->message->body, iter->message->byte_order,
|
||||
iter->pos + 1, NULL, value, len))
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
|
|
@ -2170,11 +2162,9 @@ dbus_message_iter_get_byte_array (DBusMessageIter *iter,
|
|||
int *len)
|
||||
{
|
||||
_dbus_assert (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_BYTE_ARRAY);
|
||||
|
||||
*value = _dbus_demarshal_byte_array (&iter->message->body, iter->message->byte_order,
|
||||
iter->pos + 1, NULL, len);
|
||||
|
||||
if (!*value)
|
||||
if (!_dbus_demarshal_byte_array (&iter->message->body, iter->message->byte_order,
|
||||
iter->pos + 1, NULL, value, len))
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
|
|
@ -2202,10 +2192,8 @@ dbus_message_iter_get_string_array (DBusMessageIter *iter,
|
|||
{
|
||||
_dbus_assert (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_STRING_ARRAY);
|
||||
|
||||
*value = _dbus_demarshal_string_array (&iter->message->body, iter->message->byte_order,
|
||||
iter->pos + 1, NULL, len);
|
||||
|
||||
if (!*value)
|
||||
if (!_dbus_demarshal_string_array (&iter->message->body, iter->message->byte_order,
|
||||
iter->pos + 1, NULL, value, len))
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
|
|
@ -2226,10 +2214,8 @@ dbus_message_iter_get_dict (DBusMessageIter *iter,
|
|||
{
|
||||
_dbus_assert (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_DICT);
|
||||
|
||||
*dict = _dbus_demarshal_dict (&iter->message->body, iter->message->byte_order,
|
||||
iter->pos + 1, NULL);
|
||||
|
||||
if (!*dict)
|
||||
if (!_dbus_demarshal_dict (&iter->message->body, iter->message->byte_order,
|
||||
iter->pos + 1, NULL, dict))
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
|
|
@ -3076,6 +3062,17 @@ check_message_handling (DBusMessage *message)
|
|||
dbus_free (str);
|
||||
}
|
||||
break;
|
||||
case DBUS_TYPE_BOOLEAN_ARRAY:
|
||||
{
|
||||
unsigned char *values;
|
||||
int len;
|
||||
|
||||
if (!dbus_message_iter_get_boolean_array (iter, &values, &len))
|
||||
return FALSE;
|
||||
|
||||
dbus_free (values);
|
||||
}
|
||||
break;
|
||||
case DBUS_TYPE_INT32_ARRAY:
|
||||
{
|
||||
dbus_int32_t *values;
|
||||
|
|
@ -3127,7 +3124,6 @@ check_message_handling (DBusMessage *message)
|
|||
|
||||
if (!dbus_message_iter_get_dict (iter, &dict))
|
||||
return FALSE;
|
||||
|
||||
dbus_dict_unref (dict);
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -2394,7 +2394,9 @@ _dbus_string_validate_utf8 (const DBusString *str,
|
|||
int len)
|
||||
{
|
||||
/* FIXME actually validate UTF-8 */
|
||||
return _dbus_string_validate_ascii (str, start, len);
|
||||
return TRUE;
|
||||
|
||||
/*return _dbus_string_validate_ascii (str, start, len);*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
44
test/data/valid-messages/emptiness.message
Normal file
44
test/data/valid-messages/emptiness.message
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
# Empty arrays and strings
|
||||
|
||||
VALID_HEADER
|
||||
FIELD_NAME name
|
||||
TYPE STRING
|
||||
STRING 'org.freedesktop.Foo'
|
||||
END_LENGTH Header
|
||||
ALIGN 8
|
||||
START_LENGTH Body
|
||||
TYPE STRING
|
||||
INT32 0
|
||||
BYTE 0 # Strings need to be NULL-terminated
|
||||
TYPE BOOLEAN_ARRAY
|
||||
INT32 0
|
||||
TYPE INT32_ARRAY
|
||||
INT32 0
|
||||
TYPE UINT32_ARRAY
|
||||
INT32 0
|
||||
TYPE DOUBLE_ARRAY
|
||||
INT32 0
|
||||
TYPE BYTE_ARRAY
|
||||
INT32 0
|
||||
TYPE STRING_ARRAY
|
||||
INT32 0
|
||||
TYPE DICT
|
||||
INT32 0
|
||||
|
||||
# A dict with empty arrays
|
||||
TYPE DICT
|
||||
STRING_ARRAY {'boolean_array', 'int32_array' , 'uint32_array', 'double_array', 'byte_array', 'string_array' }
|
||||
TYPE BOOLEAN_ARRAY
|
||||
INT32 0
|
||||
TYPE INT32_ARRAY
|
||||
INT32 0
|
||||
TYPE UINT32_ARRAY
|
||||
INT32 0
|
||||
TYPE DOUBLE_ARRAY
|
||||
INT32 0
|
||||
TYPE BYTE_ARRAY
|
||||
INT32 0
|
||||
TYPE STRING_ARRAY
|
||||
INT32 0
|
||||
END_LENGTH Body
|
||||
|
||||
Loading…
Add table
Reference in a new issue