<refsect1>
<title>Description</title>
- <para><function>sd_bus_message_read_strv()</function> gives access to an array of strings in message
- <parameter>m</parameter>. The "read pointer" in the message must be right before an array of strings. On
- success, a pointer to the <constant>NULL</constant>-terminated array of strings is returned in the output
- parameter <parameter>l</parameter>. Note that ownership of this array is transferred to the caller.
- Hence, the caller is responsible for freeing this array and its contents.</para>
+ <para><function>sd_bus_message_read_strv()</function> gives access to an array of string-like items in
+ message <parameter>m</parameter>. The "read pointer" in the message must be right before an array of
+ strings (D-Bus type <literal>as</literal>), object paths (D-Bus type <literal>ao</literal>), or
+ signatures (D-Bus type <literal>ag</literal>). On success, a pointer to a
+ <constant>NULL</constant>-terminated array of strings is returned in the output parameter
+ <parameter>l</parameter>. Note that ownership of this array is transferred to the caller. Hence, the
+ caller is responsible for freeing this array and its contents.</para>
</refsect1>
<refsect1>
<listitem><para>The message cannot be parsed.</para></listitem>
</varlistentry>
+
+ <varlistentry>
+ <term><constant>-ENXIO</constant></term>
+
+ <listitem><para>The message "read pointer" is not right before an array of the appropriate type.
+ </para></listitem>
+ </varlistentry>
</variablelist>
</refsect2>
</refsect1>
}
int bus_message_read_strv_extend(sd_bus_message *m, char ***l) {
- const char *s;
+ char type;
+ const char *contents, *s;
int r;
assert(m);
assert(l);
- r = sd_bus_message_enter_container(m, 'a', "s");
+ r = sd_bus_message_peek_type(m, &type, &contents);
+ if (r < 0)
+ return r;
+
+ if (type != SD_BUS_TYPE_ARRAY || !STR_IN_SET(contents, "s", "o", "g"))
+ return -ENXIO;
+
+ r = sd_bus_message_enter_container(m, 'a', NULL);
if (r <= 0)
return r;
- while ((r = sd_bus_message_read_basic(m, 's', &s)) > 0) {
+ /* sd_bus_message_read_basic() does content validation for us. */
+ while ((r = sd_bus_message_read_basic(m, *contents, &s)) > 0) {
r = strv_extend(l, s);
if (r < 0)
return r;