varlink: in varlink_observe() correctly collect error parameters

In varlink errors can have parameters (and they regularly do, for
example the io.systemd.System error we generate carries the errno in its
parameter), hence it's essential that varlink_oberserve collects that
properly and returns it too.
This commit is contained in:
Lennart Poettering
2024-01-17 16:14:10 +01:00
parent a4562f945d
commit c171b67a10
+6
View File
@@ -2285,6 +2285,10 @@ static int collect_callback(
/* If we hit an error, we will drop all collected replies and just return the error_id and flags in varlink_collect() */
if (error_id) {
context->error_id = error_id;
json_variant_unref(context->parameters);
context->parameters = json_variant_ref(parameters);
return 0;
}
@@ -2337,6 +2341,8 @@ int varlink_collect(
/* If we get an error from any of the replies, return immediately with just the error_id and flags*/
if (context.error_id) {
if (ret_parameters)
*ret_parameters = TAKE_PTR(context.parameters);
if (ret_error_id)
*ret_error_id = TAKE_PTR(context.error_id);
if (ret_flags)