summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-marshal-recursive-util.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2005-01-24 05:56:25 +0000
committerHavoc Pennington <hp@redhat.com>2005-01-24 05:56:25 +0000
commit72c433f80ba964f03688b61ff754b1c93d0fb4ad (patch)
tree0247b62780feaa20358679b9fce9a0e2c8b74a44 /dbus/dbus-marshal-recursive-util.c
parent9d21554dd3b560952cd5aa607c4ec07898c0b260 (diff)
2005-01-24 Havoc Pennington <hp@redhat.com>
* dbus/dbus-message-factory.c: more testing of message validation * dbus/dbus-protocol.h (DBUS_MINIMUM_HEADER_SIZE): move to this header
Diffstat (limited to 'dbus/dbus-marshal-recursive-util.c')
-rw-r--r--dbus/dbus-marshal-recursive-util.c109
1 files changed, 99 insertions, 10 deletions
diff --git a/dbus/dbus-marshal-recursive-util.c b/dbus/dbus-marshal-recursive-util.c
index e257a51c..493672b6 100644
--- a/dbus/dbus-marshal-recursive-util.c
+++ b/dbus/dbus-marshal-recursive-util.c
@@ -1425,6 +1425,87 @@ value_generator (int *ip)
}
static void
+build_body (TestTypeNode **nodes,
+ int n_nodes,
+ int byte_order,
+ DBusString *signature,
+ DBusString *body)
+{
+ int i;
+ DataBlock block;
+ DBusTypeReader reader;
+ DBusTypeWriter writer;
+
+ i = 0;
+ while (i < n_nodes)
+ {
+ if (! node_build_signature (nodes[i], signature))
+ _dbus_assert_not_reached ("no memory");
+
+ ++i;
+ }
+
+ if (!data_block_init (&block, byte_order, 0))
+ _dbus_assert_not_reached ("no memory");
+
+ data_block_init_reader_writer (&block,
+ &reader, &writer);
+
+ /* DBusTypeWriter assumes it's writing into an existing signature,
+ * so doesn't add nul on its own. We have to do that.
+ */
+ if (!_dbus_string_insert_byte (&block.signature,
+ 0, '\0'))
+ _dbus_assert_not_reached ("no memory");
+
+ i = 0;
+ while (i < n_nodes)
+ {
+ if (!node_write_value (nodes[i], &block, &writer, i))
+ _dbus_assert_not_reached ("no memory");
+
+ ++i;
+ }
+
+ if (!_dbus_string_copy_len (&block.body, 0,
+ _dbus_string_get_length (&block.body) - N_FENCE_BYTES,
+ body, 0))
+ _dbus_assert_not_reached ("oom");
+
+ data_block_free (&block);
+}
+
+dbus_bool_t
+dbus_internal_do_not_use_generate_bodies (int sequence,
+ int byte_order,
+ DBusString *signature,
+ DBusString *body)
+{
+ TestTypeNode *nodes[1];
+ int i;
+ int n_nodes;
+
+ nodes[0] = value_generator (&sequence);
+
+ if (nodes[0] == NULL)
+ return FALSE;
+
+ n_nodes = 1;
+
+ build_body (nodes, n_nodes, byte_order, signature, body);
+
+
+ i = 0;
+ while (i < n_nodes)
+ {
+ node_destroy (nodes[i]);
+ ++i;
+ }
+
+ return TRUE;
+}
+
+static void
make_and_run_values_inside_container (const TestTypeNodeClass *container_klass,
int n_nested)
{
@@ -2305,18 +2386,26 @@ object_path_from_seed (char *buf,
v = (unsigned char) ('A' + seed);
- i = 0;
- while (i + 1 < len)
+ if (len < 2)
{
- if (v < 'A' || v > 'z')
- v = 'A';
-
- buf[i] = '/';
- ++i;
- buf[i] = v;
- ++i;
+ buf[0] = '/';
+ i = 1;
+ }
+ else
+ {
+ i = 0;
+ while (i + 1 < len)
+ {
+ if (v < 'A' || v > 'z')
+ v = 'A';
- v += 1;
+ buf[i] = '/';
+ ++i;
+ buf[i] = v;
+ ++i;
+
+ v += 1;
+ }
}
buf[i] = '\0';