D-Bus 1.15.8
Data Structures | Macros | Enumerations | Functions

functions to marshal/unmarshal data from the wire More...

Data Structures

struct  HeaderFieldType
 
struct  DBusTypeReaderClass
 Virtual table for a type reader. More...
 
struct  ReplacementBlock
 

Macros

#define FIELDS_ARRAY_SIGNATURE_OFFSET   6
 Offset from start of _dbus_header_signature_str to the signature of the fields array. More...
 
#define FIELDS_ARRAY_ELEMENT_SIGNATURE_OFFSET   7
 Offset from start of _dbus_header_signature_str to the signature of an element of the fields array. More...
 
#define BYTE_ORDER_OFFSET   0
 Offset to byte order from start of header. More...
 
#define TYPE_OFFSET   1
 Offset to type from start of header. More...
 
#define FLAGS_OFFSET   2
 Offset to flags from start of header. More...
 
#define VERSION_OFFSET   3
 Offset to version from start of header. More...
 
#define BODY_LENGTH_OFFSET   4
 Offset to body length from start of header. More...
 
#define SERIAL_OFFSET   8
 Offset to client serial from start of header. More...
 
#define FIELDS_ARRAY_LENGTH_OFFSET   12
 Offset to fields array length from start of header. More...
 
#define FIRST_FIELD_OFFSET   16
 Offset to first field in header. More...
 
#define EXPECTED_TYPE_OF_FIELD(field)   (_dbus_header_field_types[field].type)
 Macro to look up the correct type for a field. More...
 
#define MAX_POSSIBLE_HEADER_PADDING   7
 The most padding we could ever need for a header. More...
 
#define HEADER_END_BEFORE_PADDING(header)    (_dbus_string_get_length (&(header)->data) - (header)->padding)
 Compute the end of the header, ignoring padding. More...
 
#define RECURSIVE_MARSHAL_READ_TRACE   0
 turn this on to get deluged in TypeReader verbose spam More...
 
#define RECURSIVE_MARSHAL_WRITE_TRACE   0
 turn this on to get deluged in TypeWriter verbose spam More...
 
#define ARRAY_READER_LEN_POS(reader)    ((reader)->u.array.start_pos - ((int)(reader)->array_len_offset) - 4)
 compute position of array length given array_len_offset, which is the offset back from start_pos to end of the len More...
 
#define VALID_INITIAL_NAME_CHARACTER(c)
 Determine wether the given character is valid as the first character in a name. More...
 
#define VALID_NAME_CHARACTER(c)
 Determine wether the given character is valid as a second or later character in a name. More...
 
#define VALID_INITIAL_BUS_NAME_CHARACTER(c)
 Determine wether the given character is valid as the first character in a bus name. More...
 
#define VALID_BUS_NAME_CHARACTER(c)
 Determine wether the given character is valid as a second or later character in a bus name. More...
 
#define _dbus_validate_utf8(s, b, e)   _dbus_string_validate_utf8 (s, b, e)
 
#define DECLARE_DBUS_NAME_CHECK(what)   dbus_bool_t _dbus_check_is_valid_##what (const char *name)
 A name check is used in _dbus_return_if_fail(), it's not suitable for validating untrusted data. More...
 
#define DEFINE_DBUS_NAME_CHECK(what)
 Define a name check to be used in _dbus_return_if_fail() statements. More...
 

Enumerations

enum  { MARSHAL_AS_STRING , MARSHAL_AS_SIGNATURE , MARSHAL_AS_BYTE_ARRAY }
 
enum  DBusValidationMode { DBUS_VALIDATION_MODE_WE_TRUST_THIS_DATA_ABSOLUTELY , DBUS_VALIDATION_MODE_DATA_IS_UNTRUSTED }
 This is used rather than a bool for high visibility. More...
 
enum  DBusValidity {
  DBUS_VALIDITY_UNKNOWN_OOM_ERROR = -4 , DBUS_INVALID_FOR_UNKNOWN_REASON = -3 , DBUS_VALID_BUT_INCOMPLETE = -2 , DBUS_VALIDITY_UNKNOWN = -1 ,
  DBUS_VALID = 0 , DBUS_INVALID_UNKNOWN_TYPECODE = 1 , DBUS_INVALID_MISSING_ARRAY_ELEMENT_TYPE = 2 , DBUS_INVALID_SIGNATURE_TOO_LONG = 3 ,
  DBUS_INVALID_EXCEEDED_MAXIMUM_ARRAY_RECURSION = 4 , DBUS_INVALID_EXCEEDED_MAXIMUM_STRUCT_RECURSION = 5 , DBUS_INVALID_STRUCT_ENDED_BUT_NOT_STARTED = 6 , DBUS_INVALID_STRUCT_STARTED_BUT_NOT_ENDED = 7 ,
  DBUS_INVALID_STRUCT_HAS_NO_FIELDS = 8 , DBUS_INVALID_ALIGNMENT_PADDING_NOT_NUL = 9 , DBUS_INVALID_BOOLEAN_NOT_ZERO_OR_ONE = 10 , DBUS_INVALID_NOT_ENOUGH_DATA = 11 ,
  DBUS_INVALID_TOO_MUCH_DATA = 12 , DBUS_INVALID_BAD_BYTE_ORDER = 13 , DBUS_INVALID_BAD_PROTOCOL_VERSION = 14 , DBUS_INVALID_BAD_MESSAGE_TYPE = 15 ,
  DBUS_INVALID_BAD_SERIAL = 16 , DBUS_INVALID_INSANE_FIELDS_ARRAY_LENGTH = 17 , DBUS_INVALID_INSANE_BODY_LENGTH = 18 , DBUS_INVALID_MESSAGE_TOO_LONG = 19 ,
  DBUS_INVALID_HEADER_FIELD_CODE = 20 , DBUS_INVALID_HEADER_FIELD_HAS_WRONG_TYPE = 21 , DBUS_INVALID_USES_LOCAL_INTERFACE = 22 , DBUS_INVALID_USES_LOCAL_PATH = 23 ,
  DBUS_INVALID_HEADER_FIELD_APPEARS_TWICE = 24 , DBUS_INVALID_BAD_DESTINATION = 25 , DBUS_INVALID_BAD_INTERFACE = 26 , DBUS_INVALID_BAD_MEMBER = 27 ,
  DBUS_INVALID_BAD_ERROR_NAME = 28 , DBUS_INVALID_BAD_SENDER = 29 , DBUS_INVALID_MISSING_PATH = 30 , DBUS_INVALID_MISSING_INTERFACE = 31 ,
  DBUS_INVALID_MISSING_MEMBER = 32 , DBUS_INVALID_MISSING_ERROR_NAME = 33 , DBUS_INVALID_MISSING_REPLY_SERIAL = 34 , DBUS_INVALID_LENGTH_OUT_OF_BOUNDS = 35 ,
  DBUS_INVALID_ARRAY_LENGTH_EXCEEDS_MAXIMUM = 36 , DBUS_INVALID_BAD_PATH = 37 , DBUS_INVALID_SIGNATURE_LENGTH_OUT_OF_BOUNDS = 38 , DBUS_INVALID_BAD_UTF8_IN_STRING = 39 ,
  DBUS_INVALID_ARRAY_LENGTH_INCORRECT = 40 , DBUS_INVALID_VARIANT_SIGNATURE_LENGTH_OUT_OF_BOUNDS = 41 , DBUS_INVALID_VARIANT_SIGNATURE_BAD = 42 , DBUS_INVALID_VARIANT_SIGNATURE_EMPTY = 43 ,
  DBUS_INVALID_VARIANT_SIGNATURE_SPECIFIES_MULTIPLE_VALUES = 44 , DBUS_INVALID_VARIANT_SIGNATURE_MISSING_NUL = 45 , DBUS_INVALID_STRING_MISSING_NUL = 46 , DBUS_INVALID_SIGNATURE_MISSING_NUL = 47 ,
  DBUS_INVALID_EXCEEDED_MAXIMUM_DICT_ENTRY_RECURSION = 48 , DBUS_INVALID_DICT_ENTRY_ENDED_BUT_NOT_STARTED = 49 , DBUS_INVALID_DICT_ENTRY_STARTED_BUT_NOT_ENDED = 50 , DBUS_INVALID_DICT_ENTRY_HAS_NO_FIELDS = 51 ,
  DBUS_INVALID_DICT_ENTRY_HAS_ONLY_ONE_FIELD = 52 , DBUS_INVALID_DICT_ENTRY_HAS_TOO_MANY_FIELDS = 53 , DBUS_INVALID_DICT_ENTRY_NOT_INSIDE_ARRAY = 54 , DBUS_INVALID_DICT_KEY_MUST_BE_BASIC_TYPE = 55 ,
  DBUS_INVALID_MISSING_UNIX_FDS = 56 , DBUS_INVALID_NESTED_TOO_DEEPLY = 57 , DBUS_VALIDITY_LAST
}
 This is primarily used in unit testing, so we can verify that each invalid message is invalid for the expected reasons. More...
 

Functions

void _dbus_pack_uint32 (dbus_uint32_t value, int byte_order, unsigned char *data)
 Packs a 32 bit unsigned integer into a data pointer. More...
 
dbus_uint16_t _dbus_unpack_uint16 (int byte_order, const unsigned char *data)
 Unpacks a 16 bit unsigned integer from a data pointer. More...
 
dbus_uint32_t _dbus_unpack_uint32 (int byte_order, const unsigned char *data)
 Unpacks a 32 bit unsigned integer from a data pointer. More...
 
void _dbus_marshal_set_uint32 (DBusString *str, int pos, dbus_uint32_t value, int byte_order)
 Sets the 4 bytes at the given offset to a marshaled unsigned integer, replacing anything found there previously. More...
 
dbus_bool_t _dbus_marshal_set_basic (DBusString *str, int pos, int type, const void *value, int byte_order, int *old_end_pos, int *new_end_pos)
 Sets an existing basic type value to a new value. More...
 
dbus_uint32_t _dbus_marshal_read_uint32 (const DBusString *str, int pos, int byte_order, int *new_pos)
 Convenience function to demarshal a 32 bit unsigned integer. More...
 
void _dbus_marshal_read_basic (const DBusString *str, int pos, int type, void *value, int byte_order, int *new_pos)
 Demarshals a basic-typed value. More...
 
dbus_bool_t _dbus_marshal_write_basic (DBusString *str, int insert_at, int type, const void *value, int byte_order, int *pos_after)
 Marshals a basic-typed value. More...
 
void _dbus_swap_array (unsigned char *data, int n_elements, int alignment)
 Swaps the elements of an array to the opposite byte order. More...
 
dbus_bool_t _dbus_marshal_write_fixed_multi (DBusString *str, int insert_at, int element_type, const void *value, int n_elements, int byte_order, int *pos_after)
 Marshals a block of values of fixed-length type all at once, as an optimization. More...
 
void _dbus_marshal_skip_basic (const DBusString *str, int type, int byte_order, int *pos)
 Skips over a basic-typed value, reporting the following position. More...
 
void _dbus_marshal_skip_array (const DBusString *str, int element_type, int byte_order, int *pos)
 Skips an array, returning the next position. More...
 
int _dbus_type_get_alignment (int typecode)
 Gets the alignment requirement for the given type; will be 1, 2, 4, or 8. More...
 
const char * _dbus_type_to_string (int typecode)
 Returns a string describing the given type. More...
 
void _dbus_verbose_bytes (const unsigned char *data, int len, int offset)
 If in verbose mode, print a block of binary data. More...
 
void _dbus_verbose_bytes_of_string (const DBusString *str, int start, int len)
 Dump the given part of the string to verbose log. More...
 
int _dbus_first_type_in_signature (const DBusString *str, int pos)
 Get the first type in the signature. More...
 
int _dbus_first_type_in_signature_c_str (const char *str, int pos)
 Similar to _dbus_first_type_in_signature, but operates on a C string buffer. More...
 
void _dbus_marshal_byteswap (const DBusString *signature, int signature_start, int old_byte_order, int new_byte_order, DBusString *value_str, int value_pos)
 Byteswaps the marshaled data in the given value_str. More...
 
 _DBUS_STRING_DEFINE_STATIC (_dbus_header_signature_str, DBUS_HEADER_SIGNATURE)
 Static DBusString containing the signature of a message header.
 
 _DBUS_STRING_DEFINE_STATIC (_dbus_local_interface_str, DBUS_INTERFACE_LOCAL)
 Static DBusString containing the local interface.
 
 _DBUS_STRING_DEFINE_STATIC (_dbus_local_path_str, DBUS_PATH_LOCAL)
 Static DBusString containing the local path.
 
char _dbus_header_get_byte_order (const DBusHeader *header)
 Returns the header's byte order. More...
 
int _dbus_header_get_message_type (DBusHeader *header)
 Gets the type of the message. More...
 
void _dbus_header_set_serial (DBusHeader *header, dbus_uint32_t serial)
 Sets the serial number of a header. More...
 
dbus_uint32_t _dbus_header_get_serial (DBusHeader *header)
 See dbus_message_get_serial() More...
 
void _dbus_header_reinit (DBusHeader *header)
 Re-initializes a header that was previously initialized and never freed. More...
 
dbus_bool_t _dbus_header_init (DBusHeader *header)
 Initializes a header, but doesn't prepare it for use; to make the header valid, you have to call _dbus_header_create(). More...
 
void _dbus_header_free (DBusHeader *header)
 Frees a header. More...
 
dbus_bool_t _dbus_header_copy (const DBusHeader *header, DBusHeader *dest)
 Initializes dest with a copy of the given header. More...
 
dbus_bool_t _dbus_header_create (DBusHeader *header, int byte_order, int message_type, const char *destination, const char *path, const char *interface, const char *member, const char *error_name)
 Fills in the primary fields of the header, so the header is ready for use. More...
 
dbus_bool_t _dbus_header_have_message_untrusted (int max_message_length, DBusValidity *validity, int *byte_order, int *fields_array_len, int *header_len, int *body_len, const DBusString *str, int start, int len)
 Given data long enough to contain the length of the message body and the fields array, check whether the data is long enough to contain the entire message (assuming the claimed lengths are accurate). More...
 
dbus_bool_t _dbus_header_load (DBusHeader *header, DBusValidationMode mode, DBusValidity *validity, int byte_order, int fields_array_len, int header_len, int body_len, const DBusString *str)
 Creates a message header from potentially-untrusted data. More...
 
void _dbus_header_update_lengths (DBusHeader *header, int body_len)
 Fills in the correct body length. More...
 
dbus_bool_t _dbus_header_set_field_basic (DBusHeader *header, int field, int type, const void *value)
 Sets the value of a field with basic type. More...
 
dbus_bool_t _dbus_header_get_field_basic (DBusHeader *header, int field, int type, void *value)
 Gets the value of a field with basic type. More...
 
dbus_bool_t _dbus_header_get_field_raw (DBusHeader *header, int field, const DBusString **str, int *pos)
 Gets the raw marshaled data for a field. More...
 
dbus_bool_t _dbus_header_delete_field (DBusHeader *header, int field)
 Deletes a field, if it exists. More...
 
void _dbus_header_toggle_flag (DBusHeader *header, dbus_uint32_t flag, dbus_bool_t value)
 Toggles a message flag bit, turning on the bit if value = TRUE and flipping it off if value = FALSE. More...
 
dbus_bool_t _dbus_header_get_flag (DBusHeader *header, dbus_uint32_t flag)
 Gets a message flag bit, returning TRUE if the bit is set. More...
 
void _dbus_header_byteswap (DBusHeader *header, int new_order)
 Swaps the header into the given order if required. More...
 
dbus_bool_t _dbus_header_remove_unknown_fields (DBusHeader *header)
 Remove every header field not known to this version of dbus. More...
 
void _dbus_type_signature_next (const char *type_str, int *type_pos)
 Skips to the next "complete" type inside a type signature. More...
 
void _dbus_type_reader_init (DBusTypeReader *reader, int byte_order, const DBusString *type_str, int type_pos, const DBusString *value_str, int value_pos)
 Initializes a type reader. More...
 
void _dbus_type_reader_init_types_only (DBusTypeReader *reader, const DBusString *type_str, int type_pos)
 Like _dbus_type_reader_init() but the iteration is over the signature, not over values. More...
 
int _dbus_type_reader_get_current_type (const DBusTypeReader *reader)
 Gets the type of the value the reader is currently pointing to; or for a types-only reader gets the type it's currently pointing to. More...
 
int _dbus_type_reader_get_element_type (const DBusTypeReader *reader)
 Gets the type of an element of the array the reader is currently pointing to. More...
 
int _dbus_type_reader_get_value_pos (const DBusTypeReader *reader)
 Gets the current position in the value block. More...
 
void _dbus_type_reader_read_raw (const DBusTypeReader *reader, const unsigned char **value_location)
 Get the address of the marshaled value in the data being read. More...
 
void _dbus_type_reader_read_basic (const DBusTypeReader *reader, void *value)
 Reads a basic-typed value, as with _dbus_marshal_read_basic(). More...
 
int _dbus_type_reader_get_array_length (const DBusTypeReader *reader)
 Returns the number of bytes in the array. More...
 
void _dbus_type_reader_read_fixed_multi (const DBusTypeReader *reader, const void **value, int *n_elements)
 Reads a block of fixed-length basic values, from the current point in an array to the end of the array. More...
 
void _dbus_type_reader_recurse (DBusTypeReader *reader, DBusTypeReader *sub)
 Initialize a new reader pointing to the first type and corresponding value that's a child of the current container. More...
 
dbus_bool_t _dbus_type_reader_next (DBusTypeReader *reader)
 Skip to the next value on this "level". More...
 
dbus_bool_t _dbus_type_reader_has_next (const DBusTypeReader *reader)
 Check whether there's another value on this "level". More...
 
void _dbus_type_reader_get_signature (const DBusTypeReader *reader, const DBusString **str_p, int *start_p, int *len_p)
 Gets the string and range of said string containing the signature of the current value. More...
 
dbus_bool_t _dbus_type_reader_set_basic (DBusTypeReader *reader, const void *value, const DBusTypeReader *realign_root)
 Sets a new value for the basic type value pointed to by the reader, leaving the reader valid to continue reading. More...
 
dbus_bool_t _dbus_type_reader_delete (DBusTypeReader *reader, const DBusTypeReader *realign_root)
 Recursively deletes any value pointed to by the reader, leaving the reader valid to continue reading. More...
 
void _dbus_type_writer_init (DBusTypeWriter *writer, int byte_order, DBusString *type_str, int type_pos, DBusString *value_str, int value_pos)
 Initialize a write iterator, which is used to write out values in serialized D-Bus format. More...
 
void _dbus_type_writer_init_types_delayed (DBusTypeWriter *writer, int byte_order, DBusString *value_str, int value_pos)
 Initialize a write iterator, with the signature to be provided later. More...
 
void _dbus_type_writer_add_types (DBusTypeWriter *writer, DBusString *type_str, int type_pos)
 Adds type string to the writer, if it had none. More...
 
void _dbus_type_writer_remove_types (DBusTypeWriter *writer)
 Removes type string from the writer. More...
 
void _dbus_type_writer_init_values_only (DBusTypeWriter *writer, int byte_order, const DBusString *type_str, int type_pos, DBusString *value_str, int value_pos)
 Like _dbus_type_writer_init(), except the type string passed in should correspond to an existing signature that matches what you're going to write out. More...
 
dbus_bool_t _dbus_type_writer_recurse (DBusTypeWriter *writer, int container_type, const DBusString *contained_type, int contained_type_start, DBusTypeWriter *sub)
 Opens a new container and writes out the initial information for that container. More...
 
dbus_bool_t _dbus_type_writer_append_array (DBusTypeWriter *writer, const DBusString *contained_type, int contained_type_start, DBusTypeWriter *sub)
 Append to an existing array. More...
 
dbus_bool_t _dbus_type_writer_unrecurse (DBusTypeWriter *writer, DBusTypeWriter *sub)
 Closes a container created by _dbus_type_writer_recurse() and writes any additional information to the values block. More...
 
dbus_bool_t _dbus_type_writer_write_basic (DBusTypeWriter *writer, int type, const void *value)
 Writes out a basic type. More...
 
dbus_bool_t _dbus_type_writer_write_fixed_multi (DBusTypeWriter *writer, int element_type, const void *value, int n_elements)
 Writes a block of fixed-length basic values, i.e. More...
 
dbus_bool_t _dbus_type_writer_write_reader (DBusTypeWriter *writer, DBusTypeReader *reader)
 Iterate through all values in the given reader, writing a copy of each value to the writer. More...
 
DBusValidity _dbus_validate_signature_with_reason (const DBusString *type_str, int type_pos, int len)
 Verifies that the range of type_str from type_pos to type_end is a valid signature. More...
 
DBusValidity _dbus_validate_body_with_reason (const DBusString *expected_signature, int expected_signature_start, int byte_order, int *bytes_remaining, const DBusString *value_str, int value_pos, int len)
 Verifies that the range of value_str from value_pos to value_end is a legitimate value of type expected_signature. More...
 
dbus_bool_t _dbus_validate_path (const DBusString *str, int start, int len)
 Checks that the given range of the string is a valid object path name in the D-Bus protocol. More...
 
const char * _dbus_validity_to_error_message (DBusValidity validity)
 
dbus_bool_t _dbus_validate_interface (const DBusString *str, int start, int len)
 Checks that the given range of the string is a valid interface name in the D-Bus protocol. More...
 
dbus_bool_t _dbus_validate_member (const DBusString *str, int start, int len)
 Checks that the given range of the string is a valid member name in the D-Bus protocol. More...
 
dbus_bool_t _dbus_validate_error_name (const DBusString *str, int start, int len)
 Checks that the given range of the string is a valid error name in the D-Bus protocol. More...
 
dbus_bool_t _dbus_validate_bus_name (const DBusString *str, int start, int len)
 Checks that the given range of the string is a valid bus name in the D-Bus protocol. More...
 
dbus_bool_t _dbus_validate_bus_namespace (const DBusString *str, int start, int len)
 Checks that the given range of the string is a prefix of a valid bus name in the D-Bus protocol. More...
 
 DECLARE_DBUS_NAME_CHECK (path)
 defines _dbus_check_is_valid_path()
 
 DECLARE_DBUS_NAME_CHECK (interface)
 defines _dbus_check_is_valid_interface()
 
 DECLARE_DBUS_NAME_CHECK (member)
 defines _dbus_check_is_valid_member()
 
 DECLARE_DBUS_NAME_CHECK (error_name)
 defines _dbus_check_is_valid_error_name()
 
 DECLARE_DBUS_NAME_CHECK (bus_name)
 defines _dbus_check_is_valid_bus_name()
 
 DECLARE_DBUS_NAME_CHECK (utf8)
 defines _dbus_check_is_valid_utf8()
 

Detailed Description

functions to marshal/unmarshal data from the wire

Types and functions related to converting primitive data types from wire format to native machine format, and vice versa.

A signature is just a string with multiple types one after the other. for example a type is "i" or "(ii)", a signature is "i(ii)" where i is int and (ii) is struct { int; int; }

Macro Definition Documentation

◆ _dbus_validate_utf8

#define _dbus_validate_utf8 (   s,
  b,
 
)    _dbus_string_validate_utf8 (s, b, e)

Definition at line 163 of file dbus-marshal-validate.h.

◆ ARRAY_READER_LEN_POS

#define ARRAY_READER_LEN_POS (   reader)     ((reader)->u.array.start_pos - ((int)(reader)->array_len_offset) - 4)

compute position of array length given array_len_offset, which is the offset back from start_pos to end of the len

Definition at line 216 of file dbus-marshal-recursive.c.

◆ BODY_LENGTH_OFFSET

#define BODY_LENGTH_OFFSET   4

Offset to body length from start of header.

Definition at line 63 of file dbus-marshal-header.c.

◆ BYTE_ORDER_OFFSET

#define BYTE_ORDER_OFFSET   0

Offset to byte order from start of header.

Definition at line 55 of file dbus-marshal-header.c.

◆ DECLARE_DBUS_NAME_CHECK

#define DECLARE_DBUS_NAME_CHECK (   what)    dbus_bool_t _dbus_check_is_valid_##what (const char *name)

A name check is used in _dbus_return_if_fail(), it's not suitable for validating untrusted data.

use _dbus_validate_whatever for that.

Definition at line 178 of file dbus-marshal-validate.h.

◆ DEFINE_DBUS_NAME_CHECK

#define DEFINE_DBUS_NAME_CHECK (   what)
Value:
dbus_bool_t \
_dbus_check_is_valid_##what (const char *name) \
{ \
DBusString str; \
\
if (name == NULL) \
return FALSE; \
_dbus_string_init_const (&str, name); \
return _dbus_validate_##what (&str, 0, \
}
#define NULL
A null pointer, defined appropriately for C or C++.
#define FALSE
Expands to "0".
void _dbus_string_init_const(DBusString *str, const char *value)
Initializes a constant string.
Definition: dbus-string.c:197
int _dbus_string_get_length(const DBusString *str)
Gets the length of a string (not including nul termination).
Definition: dbus-string.c:784

Define a name check to be used in _dbus_return_if_fail() statements.

Definition at line 183 of file dbus-marshal-validate.h.

◆ EXPECTED_TYPE_OF_FIELD

#define EXPECTED_TYPE_OF_FIELD (   field)    (_dbus_header_field_types[field].type)

Macro to look up the correct type for a field.

Definition at line 93 of file dbus-marshal-header.c.

◆ FIELDS_ARRAY_ELEMENT_SIGNATURE_OFFSET

#define FIELDS_ARRAY_ELEMENT_SIGNATURE_OFFSET   7

Offset from start of _dbus_header_signature_str to the signature of an element of the fields array.

Definition at line 51 of file dbus-marshal-header.c.

◆ FIELDS_ARRAY_LENGTH_OFFSET

#define FIELDS_ARRAY_LENGTH_OFFSET   12

Offset to fields array length from start of header.

Definition at line 67 of file dbus-marshal-header.c.

◆ FIELDS_ARRAY_SIGNATURE_OFFSET

#define FIELDS_ARRAY_SIGNATURE_OFFSET   6

Offset from start of _dbus_header_signature_str to the signature of the fields array.

Definition at line 49 of file dbus-marshal-header.c.

◆ FIRST_FIELD_OFFSET

#define FIRST_FIELD_OFFSET   16

Offset to first field in header.

Definition at line 69 of file dbus-marshal-header.c.

◆ FLAGS_OFFSET

#define FLAGS_OFFSET   2

Offset to flags from start of header.

Definition at line 59 of file dbus-marshal-header.c.

◆ HEADER_END_BEFORE_PADDING

#define HEADER_END_BEFORE_PADDING (   header)     (_dbus_string_get_length (&(header)->data) - (header)->padding)

Compute the end of the header, ignoring padding.

In the DBusHeader diagram, this is the distance from 0 to [B].

Definition at line 128 of file dbus-marshal-header.c.

◆ MAX_POSSIBLE_HEADER_PADDING

#define MAX_POSSIBLE_HEADER_PADDING   7

The most padding we could ever need for a header.

Definition at line 96 of file dbus-marshal-header.c.

◆ RECURSIVE_MARSHAL_READ_TRACE

#define RECURSIVE_MARSHAL_READ_TRACE   0

turn this on to get deluged in TypeReader verbose spam

Definition at line 50 of file dbus-marshal-recursive.c.

◆ RECURSIVE_MARSHAL_WRITE_TRACE

#define RECURSIVE_MARSHAL_WRITE_TRACE   0

turn this on to get deluged in TypeWriter verbose spam

Definition at line 53 of file dbus-marshal-recursive.c.

◆ SERIAL_OFFSET

#define SERIAL_OFFSET   8

Offset to client serial from start of header.

Definition at line 65 of file dbus-marshal-header.c.

◆ TYPE_OFFSET

#define TYPE_OFFSET   1

Offset to type from start of header.

Definition at line 57 of file dbus-marshal-header.c.

◆ VALID_BUS_NAME_CHARACTER

#define VALID_BUS_NAME_CHARACTER (   c)
Value:
( ((c) >= '0' && (c) <= '9') || \
((c) >= 'A' && (c) <= 'Z') || \
((c) >= 'a' && (c) <= 'z') || \
((c) == '_') || ((c) == '-'))

Determine wether the given character is valid as a second or later character in a bus name.

Definition at line 1145 of file dbus-marshal-validate.c.

◆ VALID_INITIAL_BUS_NAME_CHARACTER

#define VALID_INITIAL_BUS_NAME_CHARACTER (   c)
Value:
( ((c) >= 'A' && (c) <= 'Z') || \
((c) >= 'a' && (c) <= 'z') || \
((c) == '_') || ((c) == '-'))

Determine wether the given character is valid as the first character in a bus name.

Definition at line 1136 of file dbus-marshal-validate.c.

◆ VALID_INITIAL_NAME_CHARACTER

#define VALID_INITIAL_NAME_CHARACTER (   c)
Value:
( ((c) >= 'A' && (c) <= 'Z') || \
((c) >= 'a' && (c) <= 'z') || \
((c) == '_') )

Determine wether the given character is valid as the first character in a name.

Definition at line 817 of file dbus-marshal-validate.c.

◆ VALID_NAME_CHARACTER

#define VALID_NAME_CHARACTER (   c)
Value:
( ((c) >= '0' && (c) <= '9') || \
((c) >= 'A' && (c) <= 'Z') || \
((c) >= 'a' && (c) <= 'z') || \
((c) == '_') )

Determine wether the given character is valid as a second or later character in a name.

Definition at line 826 of file dbus-marshal-validate.c.

◆ VERSION_OFFSET

#define VERSION_OFFSET   3

Offset to version from start of header.

Definition at line 61 of file dbus-marshal-header.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Definition at line 698 of file dbus-marshal-basic.c.

◆ DBusValidationMode

This is used rather than a bool for high visibility.

Definition at line 40 of file dbus-marshal-validate.h.

◆ DBusValidity

This is primarily used in unit testing, so we can verify that each invalid message is invalid for the expected reasons.

Thus we really want a distinct enum value for every codepath leaving the validator functions. Enum values are specified manually for ease of debugging (so you can see the enum value given a printf)

Enumerator
DBUS_VALIDITY_UNKNOWN_OOM_ERROR 

can't determine validity due to OOM

DBUS_VALID 

the data is valid

DBUS_INVALID_TOO_MUCH_DATA 

trailing junk makes it invalid

Definition at line 53 of file dbus-marshal-validate.h.

Function Documentation

◆ _dbus_first_type_in_signature()

int _dbus_first_type_in_signature ( const DBusString str,
int  pos 
)

Get the first type in the signature.

The difference between this and just getting the first byte of the signature is that you won't get DBUS_STRUCT_BEGIN_CHAR, you'll get DBUS_TYPE_STRUCT instead.

Parameters
strstring containing signature
poswhere the signature starts
Returns
the first type in the signature

Definition at line 1484 of file dbus-marshal-basic.c.

Referenced by _dbus_type_reader_get_current_type(), _dbus_type_reader_get_element_type(), and _dbus_type_reader_recurse().

◆ _dbus_first_type_in_signature_c_str()

int _dbus_first_type_in_signature_c_str ( const char *  str,
int  pos 
)

Similar to _dbus_first_type_in_signature, but operates on a C string buffer.

Parameters
stra C string buffer
poswhere the signature starts
Returns
the first type in the signature

Definition at line 1499 of file dbus-marshal-basic.c.

Referenced by dbus_signature_iter_get_current_type(), and dbus_signature_iter_get_element_type().

◆ _dbus_header_byteswap()

void _dbus_header_byteswap ( DBusHeader header,
int  new_order 
)

Swaps the header into the given order if required.

Parameters
headerthe header
new_orderthe new byte order

Definition at line 1507 of file dbus-marshal-header.c.

References _dbus_header_get_byte_order(), _dbus_marshal_byteswap(), _dbus_string_set_byte(), BYTE_ORDER_OFFSET, and DBusHeader::data.

◆ _dbus_header_copy()

dbus_bool_t _dbus_header_copy ( const DBusHeader header,
DBusHeader dest 
)

Initializes dest with a copy of the given header.

Resets the message serial to 0 on the copy.

Parameters
headerheader to copy
destdestination for copy
Returns
FALSE if not enough memory

Definition at line 495 of file dbus-marshal-header.c.

References _dbus_header_set_serial(), _dbus_string_copy(), _dbus_string_free(), _dbus_string_get_length(), _dbus_string_init_preallocated(), DBusHeader::data, FALSE, and TRUE.

Referenced by dbus_message_copy().

◆ _dbus_header_create()

dbus_bool_t _dbus_header_create ( DBusHeader header,
int  byte_order,
int  message_type,
const char *  destination,
const char *  path,
const char *  interface,
const char *  member,
const char *  error_name 
)

Fills in the primary fields of the header, so the header is ready for use.

NULL may be specified for some or all of the fields to avoid adding those fields. Some combinations of fields don't make sense, and passing them in will trigger an assertion failure.

Parameters
headerthe header
byte_orderbyte order of the header
message_typethe message type
destinationdestination field or NULL
pathpath field or NULL
interfaceinterface field or NULL
membermember field or NULL
error_nameerror name or NULL
Returns
FALSE if not enough memory

Definition at line 533 of file dbus-marshal-header.c.

References _dbus_assert, _dbus_string_get_length(), DBusHeader::data, DBUS_BIG_ENDIAN, DBUS_LITTLE_ENDIAN, and DBUS_MESSAGE_TYPE_SIGNAL.

◆ _dbus_header_delete_field()

dbus_bool_t _dbus_header_delete_field ( DBusHeader header,
int  field 
)

Deletes a field, if it exists.

Parameters
headerthe header
fieldthe field to delete
Returns
FALSE if no memory

Definition at line 1427 of file dbus-marshal-header.c.

◆ _dbus_header_free()

void _dbus_header_free ( DBusHeader header)

Frees a header.

Parameters
headerthe header

Definition at line 481 of file dbus-marshal-header.c.

References _dbus_string_free(), and DBusHeader::data.

Referenced by dbus_message_copy().

◆ _dbus_header_get_byte_order()

char _dbus_header_get_byte_order ( const DBusHeader header)

◆ _dbus_header_get_field_basic()

dbus_bool_t _dbus_header_get_field_basic ( DBusHeader header,
int  field,
int  type,
void *  value 
)

Gets the value of a field with basic type.

If the field doesn't exist, returns FALSE, otherwise returns TRUE.

Parameters
headerthe header
fieldthe field to get
typethe type of the value
valuethe value as for _dbus_marshal_read_basic()
Returns
FALSE if the field doesn't exist

Definition at line 1362 of file dbus-marshal-header.c.

References _dbus_assert, DBUS_HEADER_FIELD_INVALID, and DBUS_HEADER_FIELD_LAST.

Referenced by dbus_message_get_container_instance(), dbus_message_get_destination(), dbus_message_get_error_name(), dbus_message_get_interface(), dbus_message_get_member(), dbus_message_get_path(), dbus_message_get_reply_serial(), and dbus_message_get_sender().

◆ _dbus_header_get_field_raw()

dbus_bool_t _dbus_header_get_field_raw ( DBusHeader header,
int  field,
const DBusString **  str,
int *  pos 
)

Gets the raw marshaled data for a field.

If the field doesn't exist, returns FALSE, otherwise returns TRUE. Returns the start of the marshaled data, i.e. usually the byte where the length starts (for strings and arrays) or for basic types just the value itself.

Parameters
headerthe header
fieldthe field to get
strreturn location for the data string
posreturn location for start of field value
Returns
FALSE if the field doesn't exist

Definition at line 1403 of file dbus-marshal-header.c.

◆ _dbus_header_get_flag()

dbus_bool_t _dbus_header_get_flag ( DBusHeader header,
dbus_uint32_t  flag 
)

Gets a message flag bit, returning TRUE if the bit is set.

Parameters
headerthe header
flagthe message flag to get
Returns
TRUE if the flag is set

Definition at line 1490 of file dbus-marshal-header.c.

References DBusHeader::data, and FLAGS_OFFSET.

Referenced by dbus_message_get_allow_interactive_authorization(), dbus_message_get_auto_start(), and dbus_message_get_no_reply().

◆ _dbus_header_get_message_type()

int _dbus_header_get_message_type ( DBusHeader header)

Gets the type of the message.

Parameters
headerthe header
Returns
the type

Definition at line 391 of file dbus-marshal-header.c.

References _dbus_assert, _dbus_string_get_byte(), DBusHeader::data, DBUS_MESSAGE_TYPE_INVALID, and TYPE_OFFSET.

Referenced by dbus_message_get_type().

◆ _dbus_header_get_serial()

dbus_uint32_t _dbus_header_get_serial ( DBusHeader header)

See dbus_message_get_serial()

Parameters
headerthe header
Returns
the client serial

Definition at line 432 of file dbus-marshal-header.c.

References _dbus_header_get_byte_order(), _dbus_marshal_read_uint32(), DBusHeader::data, NULL, and SERIAL_OFFSET.

Referenced by _dbus_header_set_serial(), and dbus_message_get_serial().

◆ _dbus_header_have_message_untrusted()

dbus_bool_t _dbus_header_have_message_untrusted ( int  max_message_length,
DBusValidity validity,
int *  byte_order,
int *  fields_array_len,
int *  header_len,
int *  body_len,
const DBusString str,
int  start,
int  len 
)

Given data long enough to contain the length of the message body and the fields array, check whether the data is long enough to contain the entire message (assuming the claimed lengths are accurate).

Also checks that the lengths are in sanity parameters.

Parameters
max_message_lengthmaximum length of a valid message
validityreturn location for why the data is invalid if it is
byte_orderreturn location for byte order
fields_array_lenreturn location for claimed fields array length
header_lenreturn location for claimed header length
body_lenreturn location for claimed body length
strthe data
startstart of data, 8-aligned
lenlength of data
Returns
TRUE if the data is long enough for the claimed length, and the lengths were valid

Definition at line 681 of file dbus-marshal-header.c.

References _dbus_assert, _DBUS_INT32_MAX, _dbus_string_get_byte(), BYTE_ORDER_OFFSET, DBUS_BIG_ENDIAN, and DBUS_LITTLE_ENDIAN.

Referenced by _dbus_message_loader_queue_messages(), and dbus_message_demarshal_bytes_needed().

◆ _dbus_header_init()

dbus_bool_t _dbus_header_init ( DBusHeader header)

Initializes a header, but doesn't prepare it for use; to make the header valid, you have to call _dbus_header_create().

Parameters
headerheader to initialize
Returns
FALSE if not enough memory

Definition at line 465 of file dbus-marshal-header.c.

References _dbus_header_reinit(), _dbus_string_init_preallocated(), DBusHeader::data, FALSE, and TRUE.

◆ _dbus_header_load()

dbus_bool_t _dbus_header_load ( DBusHeader header,
DBusValidationMode  mode,
DBusValidity validity,
int  byte_order,
int  fields_array_len,
int  header_len,
int  body_len,
const DBusString str 
)

Creates a message header from potentially-untrusted data.

The return value is TRUE if there was enough memory and the data was valid. If it returns TRUE, the header will be created. If it returns FALSE and *validity == DBUS_VALIDITY_UNKNOWN_OOM_ERROR, then there wasn't enough memory. If it returns FALSE and *validity != DBUS_VALIDITY_UNKNOWN_OOM_ERROR then the data was invalid.

The byte_order, fields_array_len, and body_len args should be from _dbus_header_have_message_untrusted(). Validation performed in _dbus_header_have_message_untrusted() is assumed to have been already done.

Parameters
headerthe header (must be initialized)
modewhether to do validation
validityreturn location for invalidity reason
byte_orderbyte order from header
fields_array_lenclaimed length of fields array
body_lenclaimed length of body
header_lenclaimed length of header
stra string starting with the header
Returns
FALSE if no memory or data was invalid, TRUE otherwise

Definition at line 981 of file dbus-marshal-header.c.

References _dbus_assert, _dbus_string_copy_len(), _dbus_string_get_length(), DBusHeader::data, DBUS_VALIDITY_UNKNOWN_OOM_ERROR, and FALSE.

◆ _dbus_header_reinit()

void _dbus_header_reinit ( DBusHeader header)

Re-initializes a header that was previously initialized and never freed.

After this, to make the header valid you have to call _dbus_header_create().

Parameters
headerheader to re-initialize

Definition at line 448 of file dbus-marshal-header.c.

References _dbus_string_set_length(), DBusHeader::data, and DBusHeader::padding.

Referenced by _dbus_header_init().

◆ _dbus_header_remove_unknown_fields()

dbus_bool_t _dbus_header_remove_unknown_fields ( DBusHeader header)

◆ _dbus_header_set_field_basic()

dbus_bool_t _dbus_header_set_field_basic ( DBusHeader header,
int  field,
int  type,
const void *  value 
)

Sets the value of a field with basic type.

If the value is a string value, it isn't allowed to be NULL. If the field doesn't exist, it will be created.

Parameters
headerthe header
fieldthe field to set
typethe type of the value
valuethe value as for _dbus_marshal_set_basic()
Returns
FALSE if no memory

Definition at line 1284 of file dbus-marshal-header.c.

References _dbus_assert, and DBUS_HEADER_FIELD_LAST.

Referenced by dbus_message_set_reply_serial().

◆ _dbus_header_set_serial()

void _dbus_header_set_serial ( DBusHeader header,
dbus_uint32_t  serial 
)

Sets the serial number of a header.

This can only be done once on a header.

Parameters
headerthe header
serialthe serial

Definition at line 409 of file dbus-marshal-header.c.

References _dbus_assert, _dbus_header_get_byte_order(), _dbus_header_get_serial(), _dbus_marshal_set_uint32(), DBusHeader::data, and SERIAL_OFFSET.

Referenced by _dbus_header_copy(), and dbus_message_set_serial().

◆ _dbus_header_toggle_flag()

void _dbus_header_toggle_flag ( DBusHeader header,
dbus_uint32_t  flag,
dbus_bool_t  value 
)

Toggles a message flag bit, turning on the bit if value = TRUE and flipping it off if value = FALSE.

Parameters
headerthe header
flagthe message flag to toggle
valuetoggle on or off

Definition at line 1468 of file dbus-marshal-header.c.

References DBusHeader::data, and FLAGS_OFFSET.

Referenced by dbus_message_set_allow_interactive_authorization(), dbus_message_set_auto_start(), and dbus_message_set_no_reply().

◆ _dbus_header_update_lengths()

void _dbus_header_update_lengths ( DBusHeader header,
int  body_len 
)

Fills in the correct body length.

Parameters
headerthe header
body_lenthe length of the body

Definition at line 1207 of file dbus-marshal-header.c.

References _dbus_header_get_byte_order(), _dbus_marshal_set_uint32(), BODY_LENGTH_OFFSET, and DBusHeader::data.

Referenced by dbus_message_lock().

◆ _dbus_marshal_byteswap()

void _dbus_marshal_byteswap ( const DBusString signature,
int  signature_start,
int  old_byte_order,
int  new_byte_order,
DBusString value_str,
int  value_pos 
)

Byteswaps the marshaled data in the given value_str.

Parameters
signaturethe types in the value_str
signature_startwhere in signature is the signature
old_byte_orderthe old byte order
new_byte_orderthe new byte order
value_strthe string containing the body
value_poswhere the values start

Definition at line 224 of file dbus-marshal-byteswap.c.

References _dbus_assert, _dbus_string_get_length(), and _dbus_type_reader_init_types_only().

Referenced by _dbus_header_byteswap().

◆ _dbus_marshal_read_basic()

void _dbus_marshal_read_basic ( const DBusString str,
int  pos,
int  type,
void *  value,
int  byte_order,
int *  new_pos 
)

Demarshals a basic-typed value.

The "value" pointer is always the address of a variable of the basic type. So e.g. if the basic type is "double" then the pointer is a double*, and if it's "char*" then the pointer is a "char**".

A value of type DBusBasicValue is guaranteed to be large enough to hold any of the types that may be returned, which is handy if you are trying to do things generically. For example you can pass a DBusBasicValue* in to this function, and then pass the same DBusBasicValue* in to _dbus_marshal_basic_type() in order to move a value from one place to another.

Parameters
strthe string containing the data
posposition in the string
typetype of value to demarshal
valuepointer to return value data
byte_orderthe byte order
new_pospointer to update with new position, or NULL

Definition at line 514 of file dbus-marshal-basic.c.

References _dbus_assert, _dbus_assert_not_reached, _dbus_marshal_read_uint32(), _dbus_string_get_byte(), _dbus_string_get_const_data(), _dbus_type_to_string(), _dbus_warn_check_failed(), DBUS_TYPE_BOOLEAN, DBUS_TYPE_BYTE, DBUS_TYPE_DOUBLE, DBUS_TYPE_INT16, DBUS_TYPE_INT32, DBUS_TYPE_INT64, dbus_type_is_basic(), DBUS_TYPE_OBJECT_PATH, DBUS_TYPE_SIGNATURE, DBUS_TYPE_STRING, DBUS_TYPE_UINT16, DBUS_TYPE_UINT32, DBUS_TYPE_UINT64, DBUS_TYPE_UNIX_FD, and dbus_uint64_t.

Referenced by _dbus_type_reader_read_basic().

◆ _dbus_marshal_read_uint32()

dbus_uint32_t _dbus_marshal_read_uint32 ( const DBusString str,
int  pos,
int  byte_order,
int *  new_pos 
)

Convenience function to demarshal a 32 bit unsigned integer.

Parameters
strthe string containing the data
byte_orderthe byte order
posthe position in the string
new_posthe new position of the string
Returns
the demarshaled integer.

Definition at line 476 of file dbus-marshal-basic.c.

References _dbus_assert, _dbus_string_get_length(), and _dbus_unpack_uint32().

Referenced by _dbus_header_get_serial(), _dbus_marshal_read_basic(), _dbus_marshal_skip_array(), and _dbus_marshal_skip_basic().

◆ _dbus_marshal_set_basic()

dbus_bool_t _dbus_marshal_set_basic ( DBusString str,
int  pos,
int  type,
const void *  value,
int  byte_order,
int *  old_end_pos,
int *  new_end_pos 
)

Sets an existing basic type value to a new value.

Arguments work the same way as _dbus_marshal_basic_type().

Parameters
strthe string
poslocation of the current value
typethe type of the current and new values
valuethe address of the new value
byte_orderbyte order for marshaling
old_end_poslocation to store end position of the old value, or NULL
new_end_poslocation to store end position of the new value, or NULL
Returns
FALSE if no memory

Definition at line 377 of file dbus-marshal-basic.c.

References _dbus_string_set_byte(), DBUS_TYPE_BYTE, DBUS_TYPE_INT16, DBUS_TYPE_UINT16, dbus_uint64_t, and TRUE.

◆ _dbus_marshal_set_uint32()

void _dbus_marshal_set_uint32 ( DBusString str,
int  pos,
dbus_uint32_t  value,
int  byte_order 
)

Sets the 4 bytes at the given offset to a marshaled unsigned integer, replacing anything found there previously.

Parameters
strthe string to write the marshalled int to
posthe byte offset where int should be written
valuethe value
byte_orderthe byte order to use

Definition at line 260 of file dbus-marshal-basic.c.

Referenced by _dbus_header_set_serial(), and _dbus_header_update_lengths().

◆ _dbus_marshal_skip_array()

void _dbus_marshal_skip_array ( const DBusString str,
int  element_type,
int  byte_order,
int *  pos 
)

Skips an array, returning the next position.

Parameters
strthe string containing the data
element_typethe type of array elements
byte_orderthe byte order
pospointer to position in the string, updated on return to new position

Definition at line 1205 of file dbus-marshal-basic.c.

References _dbus_assert, _dbus_marshal_read_uint32(), _dbus_string_get_length(), and _dbus_type_get_alignment().

◆ _dbus_marshal_skip_basic()

void _dbus_marshal_skip_basic ( const DBusString str,
int  type,
int  byte_order,
int *  pos 
)

Skips over a basic-typed value, reporting the following position.

Parameters
strthe string containing the data
typetype of value to read
byte_orderthe byte order
pospointer to position in the string, updated on return to new position

Definition at line 1130 of file dbus-marshal-basic.c.

References _dbus_assert, _dbus_assert_not_reached, _dbus_marshal_read_uint32(), _dbus_string_get_byte(), _dbus_string_get_length(), _dbus_type_to_string(), _dbus_warn(), DBUS_BIG_ENDIAN, DBUS_LITTLE_ENDIAN, DBUS_TYPE_BOOLEAN, DBUS_TYPE_BYTE, DBUS_TYPE_DOUBLE, DBUS_TYPE_INT16, DBUS_TYPE_INT32, DBUS_TYPE_INT64, DBUS_TYPE_OBJECT_PATH, DBUS_TYPE_SIGNATURE, DBUS_TYPE_STRING, DBUS_TYPE_UINT16, DBUS_TYPE_UINT32, DBUS_TYPE_UINT64, and DBUS_TYPE_UNIX_FD.

◆ _dbus_marshal_write_basic()

dbus_bool_t _dbus_marshal_write_basic ( DBusString str,
int  insert_at,
int  type,
const void *  value,
int  byte_order,
int *  pos_after 
)

Marshals a basic-typed value.

The "value" pointer is always the address of a variable containing the basic type value. So for example for int32 it will be dbus_int32_t*, and for string it will be const char**. This is for symmetry with _dbus_marshal_read_basic() and to have a simple consistent rule.

Parameters
strstring to marshal to
insert_atwhere to insert the value
typetype of value
valuepointer to a variable containing the value
byte_orderbyte order
pos_afterNULL or the position after the type
Returns
TRUE on success

Definition at line 817 of file dbus-marshal-basic.c.

References _dbus_assert, _dbus_string_insert_byte(), DBUS_TYPE_BYTE, DBUS_TYPE_INT16, dbus_type_is_basic(), DBUS_TYPE_UINT16, dbus_uint64_t, FALSE, and TRUE.

◆ _dbus_marshal_write_fixed_multi()

dbus_bool_t _dbus_marshal_write_fixed_multi ( DBusString str,
int  insert_at,
int  element_type,
const void *  value,
int  n_elements,
int  byte_order,
int *  pos_after 
)

Marshals a block of values of fixed-length type all at once, as an optimization.

dbus_type_is_fixed() returns TRUE for fixed-length types, which are the basic types minus the string-like types.

The value argument should be the adddress of an array, so e.g. "const dbus_uint32_t**"

Parameters
strstring to marshal to
insert_atwhere to insert the value
element_typetype of array elements
valueaddress of an array to marshal
n_elementsnumber of elements in the array
byte_orderbyte order
pos_afterNULL or the position after the type
Returns
TRUE on success

Definition at line 1059 of file dbus-marshal-basic.c.

References _dbus_assert, _dbus_type_to_string(), DBUS_TYPE_BYTE, dbus_type_is_fixed(), and dbus_uint64_t.

◆ _dbus_pack_uint32()

void _dbus_pack_uint32 ( dbus_uint32_t  value,
int  byte_order,
unsigned char *  data 
)

Packs a 32 bit unsigned integer into a data pointer.

Parameters
valuethe value
byte_orderthe byte order to use
datathe data pointer

Definition at line 142 of file dbus-marshal-basic.c.

◆ _dbus_swap_array()

void _dbus_swap_array ( unsigned char *  data,
int  n_elements,
int  alignment 
)

Swaps the elements of an array to the opposite byte order.

Parameters
datastart of array
n_elementsnumber of elements
alignmentsize of each element

Definition at line 927 of file dbus-marshal-basic.c.

References _dbus_assert, and dbus_uint64_t.

◆ _dbus_type_get_alignment()

int _dbus_type_get_alignment ( int  typecode)

◆ _dbus_type_reader_delete()

dbus_bool_t _dbus_type_reader_delete ( DBusTypeReader reader,
const DBusTypeReader realign_root 
)

Recursively deletes any value pointed to by the reader, leaving the reader valid to continue reading.

Any other readers will be invalidated.

The provided realign_root is the reader to start from when realigning the data that follows the newly-set value. See _dbus_type_reader_set_basic() for more details on the realign_root paramter.

Parameters
readerreader indicating where to delete a value
realign_rootrealign from here
Returns
FALSE if not enough memory

Definition at line 1419 of file dbus-marshal-recursive.c.

References _dbus_assert, DBusTypeReader::klass, and NULL.

◆ _dbus_type_reader_get_array_length()

int _dbus_type_reader_get_array_length ( const DBusTypeReader reader)

Returns the number of bytes in the array.

Parameters
readerthe reader to read from
Returns
the number of bytes in the array

Definition at line 899 of file dbus-marshal-recursive.c.

References _dbus_assert, DBusTypeReader::klass, and DBusTypeReaderClass::types_only.

Referenced by dbus_message_iter_get_array_len(), and dbus_message_iter_get_element_count().

◆ _dbus_type_reader_get_current_type()

int _dbus_type_reader_get_current_type ( const DBusTypeReader reader)

◆ _dbus_type_reader_get_element_type()

int _dbus_type_reader_get_element_type ( const DBusTypeReader reader)

Gets the type of an element of the array the reader is currently pointing to.

It's an error to call this if _dbus_type_reader_get_current_type() doesn't return DBUS_TYPE_ARRAY for this reader.

Parameters
readerthe reader

Definition at line 820 of file dbus-marshal-recursive.c.

References _dbus_assert, _dbus_first_type_in_signature(), _dbus_type_reader_get_current_type(), DBUS_TYPE_ARRAY, DBusTypeReader::type_pos, and DBusTypeReader::type_str.

Referenced by _dbus_message_iter_get_args_valist(), and dbus_message_iter_get_element_count().

◆ _dbus_type_reader_get_signature()

void _dbus_type_reader_get_signature ( const DBusTypeReader reader,
const DBusString **  str_p,
int *  start_p,
int *  len_p 
)

Gets the string and range of said string containing the signature of the current value.

Essentially a more complete version of _dbus_type_reader_get_current_type() (returns the full type rather than only the outside of the onion).

Note though that the first byte in a struct signature is DBUS_STRUCT_BEGIN_CHAR while the current type will be DBUS_TYPE_STRUCT so it isn't true that the first byte of the signature is always the same as the current type. Another difference is that this function will still return a signature when inside an empty array; say you recurse into empty array of int32, the signature is "i" but the current type will always be DBUS_TYPE_INVALID since there are no elements to be currently pointing to.

Parameters
readerthe reader
str_pplace to return the string with the type in it
start_pplace to return start of the type
len_pplace to return the length of the type

Definition at line 1124 of file dbus-marshal-recursive.c.

References DBusTypeReader::type_pos, and DBusTypeReader::type_str.

Referenced by dbus_message_iter_get_signature().

◆ _dbus_type_reader_get_value_pos()

int _dbus_type_reader_get_value_pos ( const DBusTypeReader reader)

Gets the current position in the value block.

Parameters
readerthe reader

Definition at line 837 of file dbus-marshal-recursive.c.

References DBusTypeReader::value_pos.

◆ _dbus_type_reader_has_next()

dbus_bool_t _dbus_type_reader_has_next ( const DBusTypeReader reader)

Check whether there's another value on this "level".

e.g. the next field in a struct, the next value in an array. Returns FALSE at the end of the current container.

You probably don't want to use this; it makes for an awkward for/while loop. A nicer one is "while ((current_type = get_current_type()) != INVALID)"

Parameters
readerthe reader
Returns
FALSE if nothing more to read at or below this level

Definition at line 1093 of file dbus-marshal-recursive.c.

◆ _dbus_type_reader_init()

void _dbus_type_reader_init ( DBusTypeReader reader,
int  byte_order,
const DBusString type_str,
int  type_pos,
const DBusString value_str,
int  value_pos 
)

Initializes a type reader.

Parameters
readerthe reader
byte_orderthe byte order of the block to read
type_strthe signature of the block to read
type_poslocation of signature
value_strthe string containing values block
value_posstart of values block

Definition at line 732 of file dbus-marshal-recursive.c.

Referenced by _dbus_header_remove_unknown_fields().

◆ _dbus_type_reader_init_types_only()

void _dbus_type_reader_init_types_only ( DBusTypeReader reader,
const DBusString type_str,
int  type_pos 
)

Like _dbus_type_reader_init() but the iteration is over the signature, not over values.

Parameters
readerthe reader
type_strthe signature string
type_poslocation in the signature string

Definition at line 760 of file dbus-marshal-recursive.c.

Referenced by _dbus_marshal_byteswap(), and _dbus_validate_body_with_reason().

◆ _dbus_type_reader_next()

dbus_bool_t _dbus_type_reader_next ( DBusTypeReader reader)

Skip to the next value on this "level".

e.g. the next field in a struct, the next value in an array. Returns FALSE at the end of the current container.

Parameters
readerthe reader
Returns
FALSE if nothing more to read at or below this level

Definition at line 1053 of file dbus-marshal-recursive.c.

References _dbus_string_get_const_data_len(), _dbus_type_reader_get_current_type(), _dbus_type_to_string(), DBUS_TYPE_INVALID, FALSE, DBusTypeReader::klass, DBusTypeReaderClass::next, DBusTypeReader::type_pos, DBusTypeReader::type_str, and DBusTypeReader::value_pos.

Referenced by _dbus_message_iter_get_args_valist(), and dbus_message_iter_get_element_count().

◆ _dbus_type_reader_read_basic()

void _dbus_type_reader_read_basic ( const DBusTypeReader reader,
void *  value 
)

◆ _dbus_type_reader_read_fixed_multi()

void _dbus_type_reader_read_fixed_multi ( const DBusTypeReader reader,
const void **  value,
int *  n_elements 
)

Reads a block of fixed-length basic values, from the current point in an array to the end of the array.

Does not work for arrays of string or container types.

This function returns the array in-place; it does not make a copy, and it does not swap the bytes.

If you ask for DBUS_TYPE_DOUBLE you will get a "const double*" back and the "value" argument should be a "const double**" and so on.

Parameters
readerthe reader to read from
valueplace to return the array values
n_elementsplace to return number of array elements

Definition at line 923 of file dbus-marshal-recursive.c.

References _dbus_assert, DBusTypeReader::klass, and DBusTypeReaderClass::types_only.

Referenced by _dbus_message_iter_get_args_valist(), and dbus_message_iter_get_fixed_array().

◆ _dbus_type_reader_read_raw()

void _dbus_type_reader_read_raw ( const DBusTypeReader reader,
const unsigned char **  value_location 
)

Get the address of the marshaled value in the data being read.

The address may not be aligned; you have to align it to the type of the value you want to read. Most of the demarshal routines do this for you.

Parameters
readerthe reader
value_locationthe address of the marshaled value

Definition at line 852 of file dbus-marshal-recursive.c.

References _dbus_assert, DBusTypeReader::klass, DBusTypeReaderClass::types_only, DBusTypeReader::value_pos, and DBusTypeReader::value_str.

◆ _dbus_type_reader_recurse()

void _dbus_type_reader_recurse ( DBusTypeReader reader,
DBusTypeReader sub 
)

Initialize a new reader pointing to the first type and corresponding value that's a child of the current container.

It's an error to call this if the current type is a non-container.

Note that DBusTypeReader traverses values, not types. So if you have an empty array of array of int, you can't recurse into it. You can only recurse into each element.

Parameters
readerthe reader
suba reader to init pointing to the first child

Definition at line 987 of file dbus-marshal-recursive.c.

References _dbus_first_type_in_signature(), DBUS_TYPE_STRUCT, DBusTypeReader::klass, NULL, DBusTypeReader::type_pos, DBusTypeReader::type_str, and DBusTypeReaderClass::types_only.

Referenced by _dbus_header_remove_unknown_fields(), _dbus_message_iter_get_args_valist(), dbus_message_iter_get_element_count(), and dbus_message_iter_recurse().

◆ _dbus_type_reader_set_basic()

dbus_bool_t _dbus_type_reader_set_basic ( DBusTypeReader reader,
const void *  value,
const DBusTypeReader realign_root 
)

Sets a new value for the basic type value pointed to by the reader, leaving the reader valid to continue reading.

Any other readers will be invalidated if you set a variable-length type such as a string.

The provided realign_root is the reader to start from when realigning the data that follows the newly-set value. The reader parameter must point to a value below the realign_root parameter. If the type being set is fixed-length, then realign_root may be NULL. Only values reachable from realign_root will be realigned, so if your string contains other values you will need to deal with those somehow yourself. It is OK if realign_root is the same reader as the reader parameter, though if you aren't setting the root it may not be such a good idea.

Parameters
readerreader indicating where to set a new value
valueaddress of the value to set
realign_rootrealign from here
Returns
FALSE if not enough memory

Definition at line 1362 of file dbus-marshal-recursive.c.

References _dbus_assert, _dbus_string_get_const_data_len(), _dbus_string_get_length(), _dbus_type_reader_get_current_type(), _dbus_type_to_string(), _dbus_verbose_bytes_of_string(), dbus_type_is_basic(), dbus_type_is_fixed(), DBusTypeReader::klass, DBusTypeReader::type_pos, DBusTypeReader::type_str, DBusTypeReaderClass::types_only, DBusTypeReader::value_pos, and DBusTypeReader::value_str.

◆ _dbus_type_signature_next()

void _dbus_type_signature_next ( const char *  type_str,
int *  type_pos 
)

Skips to the next "complete" type inside a type signature.

The signature is read starting at type_pos, and the next type position is stored in the same variable.

Parameters
type_stra type signature (must be valid)
type_posan integer position in the type signature (in and out)

Definition at line 340 of file dbus-marshal-recursive.c.

References _dbus_assert, DBUS_DICT_ENTRY_BEGIN_CHAR, DBUS_DICT_ENTRY_END_CHAR, DBUS_STRUCT_BEGIN_CHAR, DBUS_STRUCT_END_CHAR, DBUS_TYPE_ARRAY, DBUS_TYPE_INVALID, NULL, and TRUE.

Referenced by dbus_signature_iter_get_signature(), and dbus_signature_iter_next().

◆ _dbus_type_to_string()

const char * _dbus_type_to_string ( int  typecode)

◆ _dbus_type_writer_add_types()

void _dbus_type_writer_add_types ( DBusTypeWriter writer,
DBusString type_str,
int  type_pos 
)

Adds type string to the writer, if it had none.

Parameters
writerthe writer to init
type_strtype string to add
type_postype position

Definition at line 1545 of file dbus-marshal-recursive.c.

References NULL, DBusTypeWriter::type_pos, and DBusTypeWriter::type_str.

◆ _dbus_type_writer_append_array()

dbus_bool_t _dbus_type_writer_append_array ( DBusTypeWriter writer,
const DBusString contained_type,
int  contained_type_start,
DBusTypeWriter sub 
)

Append to an existing array.

Essentially, the writer will read an existing length at the write location; jump over that length; and write new fields. On unrecurse(), the existing length will be updated.

Parameters
writerthe writer
contained_typeelement type
contained_type_startposition of element type
subthe subwriter to init
Returns
FALSE if no memory

Definition at line 2142 of file dbus-marshal-recursive.c.

◆ _dbus_type_writer_init()

void _dbus_type_writer_init ( DBusTypeWriter writer,
int  byte_order,
DBusString type_str,
int  type_pos,
DBusString value_str,
int  value_pos 
)

Initialize a write iterator, which is used to write out values in serialized D-Bus format.

The type_pos passed in is expected to be inside an already-valid, though potentially empty, type signature. This means that the byte after type_pos must be either DBUS_TYPE_INVALID (aka nul) or some other valid type. DBusTypeWriter won't enforce that the signature is already valid (you can append the nul byte at the end if you like), but just be aware that you need the nul byte eventually and DBusTypeWriter isn't going to write it for you.

Parameters
writerthe writer to init
byte_orderthe byte order to marshal into
type_strthe string to write typecodes into
type_poswhere to insert typecodes
value_strthe string to write values into
value_poswhere to insert values

Definition at line 1492 of file dbus-marshal-recursive.c.

References _dbus_string_get_const_data_len(), DBusTypeWriter::byte_order, DBusTypeWriter::container_type, DBUS_TYPE_INVALID, DBusTypeWriter::enabled, FALSE, TRUE, DBusTypeWriter::type_pos, DBusTypeWriter::type_pos_is_expectation, DBusTypeWriter::type_str, DBusTypeWriter::value_pos, and DBusTypeWriter::value_str.

Referenced by _dbus_type_writer_init_types_delayed(), and _dbus_type_writer_init_values_only().

◆ _dbus_type_writer_init_types_delayed()

void _dbus_type_writer_init_types_delayed ( DBusTypeWriter writer,
int  byte_order,
DBusString value_str,
int  value_pos 
)

Initialize a write iterator, with the signature to be provided later.

Parameters
writerthe writer to init
byte_orderthe byte order to marshal into
value_strthe string to write values into
value_poswhere to insert values

Definition at line 1527 of file dbus-marshal-recursive.c.

References _dbus_type_writer_init(), and NULL.

◆ _dbus_type_writer_init_values_only()

void _dbus_type_writer_init_values_only ( DBusTypeWriter writer,
int  byte_order,
const DBusString type_str,
int  type_pos,
DBusString value_str,
int  value_pos 
)

Like _dbus_type_writer_init(), except the type string passed in should correspond to an existing signature that matches what you're going to write out.

The writer will check what you write vs. this existing signature.

Parameters
writerthe writer to init
byte_orderthe byte order to marshal into
type_strthe string with signature
type_posstart of signature
value_strthe string to write values into
value_poswhere to insert values

Definition at line 1583 of file dbus-marshal-recursive.c.

References _dbus_type_writer_init(), TRUE, and DBusTypeWriter::type_pos_is_expectation.

◆ _dbus_type_writer_recurse()

dbus_bool_t _dbus_type_writer_recurse ( DBusTypeWriter writer,
int  container_type,
const DBusString contained_type,
int  contained_type_start,
DBusTypeWriter sub 
)

Opens a new container and writes out the initial information for that container.

Parameters
writerthe writer
container_typethe type of the container to open
contained_typethe array element type or variant content type
contained_type_startposition to look for the type
subthe new sub-writer to write container contents
Returns
FALSE if no memory

Definition at line 2108 of file dbus-marshal-recursive.c.

◆ _dbus_type_writer_remove_types()

void _dbus_type_writer_remove_types ( DBusTypeWriter writer)

Removes type string from the writer.

Parameters
writerthe writer to remove from

Definition at line 1562 of file dbus-marshal-recursive.c.

References NULL, DBusTypeWriter::type_pos, and DBusTypeWriter::type_str.

◆ _dbus_type_writer_unrecurse()

dbus_bool_t _dbus_type_writer_unrecurse ( DBusTypeWriter writer,
DBusTypeWriter sub 
)

Closes a container created by _dbus_type_writer_recurse() and writes any additional information to the values block.

Parameters
writerthe writer
subthe sub-writer created by _dbus_type_writer_recurse()
Returns
FALSE if no memory

Definition at line 2178 of file dbus-marshal-recursive.c.

References _dbus_assert, _dbus_type_to_string(), DBusTypeWriter::container_type, DBUS_TYPE_STRUCT, DBusTypeWriter::type_pos, DBusTypeWriter::type_pos_is_expectation, and DBusTypeWriter::value_pos.

◆ _dbus_type_writer_write_basic()

dbus_bool_t _dbus_type_writer_write_basic ( DBusTypeWriter writer,
int  type,
const void *  value 
)

Writes out a basic type.

Parameters
writerthe writer
typethe type to write
valuethe address of the value to write
Returns
FALSE if no memory

Definition at line 2310 of file dbus-marshal-recursive.c.

References _dbus_string_alloc_space(), FALSE, NULL, DBusTypeWriter::type_pos_is_expectation, and DBusTypeWriter::type_str.

◆ _dbus_type_writer_write_fixed_multi()

dbus_bool_t _dbus_type_writer_write_fixed_multi ( DBusTypeWriter writer,
int  element_type,
const void *  value,
int  n_elements 
)

Writes a block of fixed-length basic values, i.e.

those that are both dbus_type_is_fixed() and _dbus_type_is_basic(). The block must be written inside an array.

The value parameter should be the address of said array of values, so e.g. if it's an array of double, pass in "const double**"

Parameters
writerthe writer
element_typetype of stuff in the array
valueaddress of the array
n_elementsnumber of elements in the array
Returns
FALSE if no memory

Definition at line 2358 of file dbus-marshal-recursive.c.

References _dbus_assert, DBusTypeWriter::container_type, DBUS_TYPE_ARRAY, dbus_type_is_fixed(), DBusTypeWriter::type_pos, DBusTypeWriter::type_pos_is_expectation, and DBusTypeWriter::value_pos.

◆ _dbus_type_writer_write_reader()

dbus_bool_t _dbus_type_writer_write_reader ( DBusTypeWriter writer,
DBusTypeReader reader 
)

Iterate through all values in the given reader, writing a copy of each value to the writer.

The reader will be moved forward to its end position.

Parameters
writerthe writer to copy to
readerthe reader to copy from
Returns
FALSE if no memory

Definition at line 2730 of file dbus-marshal-recursive.c.

◆ _dbus_unpack_uint16()

dbus_uint16_t _dbus_unpack_uint16 ( int  byte_order,
const unsigned char *  data 
)

Unpacks a 16 bit unsigned integer from a data pointer.

Parameters
byte_orderThe byte order to use
datathe data pointer
Returns
the integer

Definition at line 168 of file dbus-marshal-basic.c.

References _dbus_assert, and DBUS_LITTLE_ENDIAN.

◆ _dbus_unpack_uint32()

dbus_uint32_t _dbus_unpack_uint32 ( int  byte_order,
const unsigned char *  data 
)

Unpacks a 32 bit unsigned integer from a data pointer.

Parameters
byte_orderThe byte order to use
datathe data pointer
Returns
the integer

Definition at line 189 of file dbus-marshal-basic.c.

References _dbus_assert, and DBUS_LITTLE_ENDIAN.

Referenced by _dbus_marshal_read_uint32(), and _dbus_verbose_bytes().

◆ _dbus_validate_body_with_reason()

DBUS_PRIVATE_EXPORT DBusValidity _dbus_validate_body_with_reason ( const DBusString expected_signature,
int  expected_signature_start,
int  byte_order,
int *  bytes_remaining,
const DBusString value_str,
int  value_pos,
int  len 
)

Verifies that the range of value_str from value_pos to value_end is a legitimate value of type expected_signature.

If this function returns TRUE, it will be safe to iterate over the values with DBusTypeReader. The signature is assumed to be already valid.

If bytes_remaining is not NULL, then leftover bytes will be stored there and DBUS_VALID returned. If it is NULL, then DBUS_INVALID_TOO_MUCH_DATA will be returned if bytes are left over.

Parameters
expected_signaturethe expected types in the value_str
expected_signature_startwhere in expected_signature is the signature
byte_orderthe byte order
bytes_remainingplace to store leftover bytes
value_strthe string containing the body
value_poswhere the values start
lenlength of values after value_pos
Returns
DBUS_VALID if valid, reason why invalid otherwise

Definition at line 767 of file dbus-marshal-validate.c.

References _dbus_assert, _dbus_string_get_const_data_len(), _dbus_string_get_length(), and _dbus_type_reader_init_types_only().

◆ _dbus_validate_bus_name()

DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_validate_bus_name ( const DBusString str,
int  start,
int  len 
)

Checks that the given range of the string is a valid bus name in the D-Bus protocol.

This includes a length restriction, etc., see the specification.

Parameters
strthe string
startfirst byte index to check
lennumber of bytes to check
Returns
TRUE if the byte range exists and is a valid name

Definition at line 1253 of file dbus-marshal-validate.c.

Referenced by dbus_validate_bus_name().

◆ _dbus_validate_bus_namespace()

DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_validate_bus_namespace ( const DBusString str,
int  start,
int  len 
)

Checks that the given range of the string is a prefix of a valid bus name in the D-Bus protocol.

Unlike _dbus_validate_bus_name(), this accepts strings with only one period-separated component.

Parameters
strthe string
startfirst byte index to check
lennumber of bytes to check
Returns
TRUE if the byte range exists and is a valid name

Definition at line 1274 of file dbus-marshal-validate.c.

◆ _dbus_validate_error_name()

DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_validate_error_name ( const DBusString str,
int  start,
int  len 
)

Checks that the given range of the string is a valid error name in the D-Bus protocol.

This includes a length restriction, etc., see the specification.

Parameters
strthe string
startfirst byte index to check
lennumber of bytes to check
Returns
TRUE if the byte range exists and is a valid name

Definition at line 1124 of file dbus-marshal-validate.c.

References _dbus_validate_interface().

Referenced by dbus_validate_error_name().

◆ _dbus_validate_interface()

DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_validate_interface ( const DBusString str,
int  start,
int  len 
)

Checks that the given range of the string is a valid interface name in the D-Bus protocol.

This includes a length restriction and an ASCII subset, see the specification.

Parameters
strthe string
startfirst byte index to check
lennumber of bytes to check
Returns
TRUE if the byte range exists and is a valid name

Definition at line 987 of file dbus-marshal-validate.c.

References _dbus_assert, _dbus_string_get_length(), DBUS_MAXIMUM_NAME_LENGTH, FALSE, NULL, TRUE, VALID_INITIAL_NAME_CHARACTER, and VALID_NAME_CHARACTER.

Referenced by _dbus_validate_error_name(), and dbus_validate_interface().

◆ _dbus_validate_member()

DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_validate_member ( const DBusString str,
int  start,
int  len 
)

Checks that the given range of the string is a valid member name in the D-Bus protocol.

This includes a length restriction, etc., see the specification.

Parameters
strthe string
startfirst byte index to check
lennumber of bytes to check
Returns
TRUE if the byte range exists and is a valid name

Definition at line 1063 of file dbus-marshal-validate.c.

References _dbus_assert, _dbus_string_get_length(), DBUS_MAXIMUM_NAME_LENGTH, FALSE, TRUE, VALID_INITIAL_NAME_CHARACTER, and VALID_NAME_CHARACTER.

Referenced by dbus_validate_member().

◆ _dbus_validate_path()

DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_validate_path ( const DBusString str,
int  start,
int  len 
)

Checks that the given range of the string is a valid object path name in the D-Bus protocol.

Part of the validation ensures that the object path contains only ASCII.

Parameters
strthe string
startfirst byte index to check
lennumber of bytes to check
Returns
TRUE if the byte range exists and is a valid name

Definition at line 849 of file dbus-marshal-validate.c.

References _dbus_assert, _dbus_string_get_length(), FALSE, TRUE, and VALID_NAME_CHARACTER.

Referenced by dbus_validate_path().

◆ _dbus_validate_signature_with_reason()

DBUS_PRIVATE_EXPORT DBusValidity _dbus_validate_signature_with_reason ( const DBusString type_str,
int  type_pos,
int  len 
)

Verifies that the range of type_str from type_pos to type_end is a valid signature.

If this function returns TRUE, it will be safe to iterate over the signature with a types-only DBusTypeReader. The range passed in should NOT include the terminating nul/DBUS_TYPE_INVALID.

Parameters
type_strthe string
type_poswhere the typecodes start
lenlength of typecodes
Returns
DBUS_VALID if valid, reason why invalid otherwise

Definition at line 53 of file dbus-marshal-validate.c.

References _dbus_assert, _DBUS_INT32_MAX, _DBUS_INT_TO_POINTER, _dbus_list_append(), DBUS_MAXIMUM_SIGNATURE_LENGTH, DBUS_MAXIMUM_TYPE_RECURSION_DEPTH, DBUS_VALID, DBUS_VALIDITY_UNKNOWN_OOM_ERROR, and NULL.

Referenced by dbus_signature_validate().

◆ _dbus_validity_to_error_message()

const char * _dbus_validity_to_error_message ( DBusValidity  validity)

Definition at line 901 of file dbus-marshal-validate.c.

◆ _dbus_verbose_bytes()

void _dbus_verbose_bytes ( const unsigned char *  data,
int  len,
int  offset 
)

If in verbose mode, print a block of binary data.

Parameters
datathe data
lenthe length of the data
offsetwhere to start counting for byte indexes

Definition at line 1351 of file dbus-marshal-basic.c.

References _dbus_assert, _dbus_unpack_uint32(), DBUS_BIG_ENDIAN, DBUS_INT64_MODIFIER, DBUS_LITTLE_ENDIAN, and dbus_uint64_t.

Referenced by _dbus_verbose_bytes_of_string().

◆ _dbus_verbose_bytes_of_string()

void _dbus_verbose_bytes_of_string ( const DBusString str,
int  start,
int  len 
)

Dump the given part of the string to verbose log.

Parameters
strthe string
startthe start of range to dump
lenlength of range

Definition at line 1428 of file dbus-marshal-basic.c.

References _dbus_assert, _dbus_string_get_const_data_len(), _dbus_string_get_length(), and _dbus_verbose_bytes().

Referenced by _dbus_read(), _dbus_read_socket(), _dbus_type_reader_set_basic(), _dbus_write(), and _dbus_write_socket().