summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMark McLoughlin <mark@skynet.ie>2003-09-25 08:50:14 +0000
committerMark McLoughlin <mark@skynet.ie>2003-09-25 08:50:14 +0000
commit46c072e1136ca101aefd5fdae35c457899d55bbb (patch)
treeaf524b3b2f0f4f094f8094311a66eea0ca6506dc /test
parentdcc037cc1f008eae9f6a35aca5b1935459e44647 (diff)
2003-09-25 Mark McLoughlin <mark@skynet.ie>
* doc/dbus-specification.sgml: don't require header fields to be 4-byte aligned and specify that fields should be distinguished from padding by the fact that zero is not a valid field name. * doc/TODO: remove re-alignment item and add item to doc the OBJECT_PATH type. * dbus/dbus-message.c: (HeaderField): rename the original member to value_offset and introduce a name_offset member to keep track of where the field actually begins. (adjust_field_offsets): remove. (append_int_field), (append_uint_field), (append_string_field): don't align the start of the header field to a 4-byte boundary. (get_next_field): impl finding the next marhsalled field after a given field. (re_align_field_recurse): impl re-aligning a number of already marshalled fields. (delete_field): impl deleting a field of any type and re-aligning any following fields. (delete_int_or_uint_field), (delete_string_field): remove. (set_int_field), (set_uint_field): no need to re-check that we have the correct type for the field. (set_string_field): ditto and impl re-aligning any following fields. (decode_header_data): update to take into account that the fields aren't 4-byte aligned any more and the new way to distinguish padding from header fields. Also, don't exit when there is too much header padding. (process_test_subdir): print the directory. (_dbus_message_test): add test to make sure a following field is re-aligned correctly after field deletion. * dbus/dbus-string.[ch]: (_dbus_string_insert_bytes): rename from insert_byte and allow the insert of multiple bytes. (_dbus_string_test): test inserting multiple bytes. * dbus/dbus-marshal.c: (_dbus_marshal_set_string): add warning note to docs about having to re-align any marshalled values following the string. * dbus/dbus-message-builder.c: (append_string_field), (_dbus_message_data_load): don't align the header field. * dbus/dbus-auth.c: (process_test_subdir): print the directory. * test/break-loader.c: (randomly_add_one_byte): upd. for insert_byte change. * test/data/invalid-messages/bad-header-field-alignment.message: new test case. * test/data/valid-messages/unknown-header-field.message: shove a dict in the unknown field.
Diffstat (limited to 'test')
-rw-r--r--test/break-loader.c4
-rw-r--r--test/data/invalid-messages/bad-header-field-alignment.message34
-rw-r--r--test/data/valid-messages/unknown-header-field.message9
3 files changed, 44 insertions, 3 deletions
diff --git a/test/break-loader.c b/test/break-loader.c
index ebe2606b..3771d7cc 100644
--- a/test/break-loader.c
+++ b/test/break-loader.c
@@ -287,8 +287,8 @@ randomly_add_one_byte (const DBusString *orig_data,
i = random_int_in_range (0, _dbus_string_get_length (mutated));
- _dbus_string_insert_byte (mutated, i,
- random_int_in_range (0, 256));
+ _dbus_string_insert_bytes (mutated, i, 1,
+ random_int_in_range (0, 256));
}
static void
diff --git a/test/data/invalid-messages/bad-header-field-alignment.message b/test/data/invalid-messages/bad-header-field-alignment.message
new file mode 100644
index 00000000..75776a37
--- /dev/null
+++ b/test/data/invalid-messages/bad-header-field-alignment.message
@@ -0,0 +1,34 @@
+## last field incorrectly aligned to 4 bytes
+
+## VALID_HEADER includes a LENGTH Header and LENGTH Body
+VALID_HEADER method_call
+
+HEADER_FIELD INTERFACE
+TYPE STRING
+STRING 'org.freedesktop.Foo'
+
+HEADER_FIELD MEMBER
+TYPE STRING
+STRING 'Bar'
+
+HEADER_FIELD UNKNOWN
+TYPE STRING
+STRING 'a'
+
+ALIGN 4
+
+HEADER_FIELD UNKNOWN
+TYPE ARRAY
+TYPE BYTE
+ALIGN 4
+LENGTH ThisByteArray
+START_LENGTH ThisByteArray
+BYTE 1
+BYTE 2
+END_LENGTH ThisByteArray
+
+
+ALIGN 8
+END_LENGTH Header
+START_LENGTH Body
+END_LENGTH Body
diff --git a/test/data/valid-messages/unknown-header-field.message b/test/data/valid-messages/unknown-header-field.message
index 973def68..ac7d624c 100644
--- a/test/data/valid-messages/unknown-header-field.message
+++ b/test/data/valid-messages/unknown-header-field.message
@@ -3,9 +3,16 @@
## VALID_HEADER includes a LENGTH Header and LENGTH Body
VALID_HEADER method_call
REQUIRED_FIELDS
+
HEADER_FIELD UNKNOWN
+TYPE DICT
+LENGTH Dict
+START_LENGTH Dict
+STRING 'int32'
TYPE INT32
-INT32 0xfeeb
+INT32 0x12345678
+END_LENGTH Dict
+
ALIGN 8
END_LENGTH Header
START_LENGTH Body