Skip to content

Commit

Permalink
linux-capture: Lookup session handle without typechecks
Browse files Browse the repository at this point in the history
g_variant_lookup() obligatorily receives the type of the variant to
lookup. This function is used when retrieving the session handle
from the portal's response, and the variant type passed is "s" (a
string).

However, xdg-desktop-portal had a bug: the documentation explicitly
mentions that the session handle is an object path (of variant type
"o"), but it passed a string (of variant type "s"). This mismatch
was fixed in the xdg-desktop-portal release 1.10 [1], but that broke
the PipeWire capture code, which was passing specifically the "s"
value to the variant lookup.

Fix this by not checking the variant type at all. Object paths ("o")
are simply strings with a few extra checks, and we don't actually need
to perform these checks.

This change probably broke other apps, and that makes me extremely sad :(

[1] flatpak/xdg-desktop-portal#609
  • Loading branch information
GeorgesStavracas authored and flaeri committed Jan 26, 2022
1 parent e8c2db1 commit 5f763cc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions plugins/linux-capture/pipewire.c
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,7 @@ static void on_create_session_response_received_cb(
UNUSED_PARAMETER(interface_name);
UNUSED_PARAMETER(signal_name);

g_autoptr(GVariant) session_handle_variant = NULL;
g_autoptr(GVariant) result = NULL;
struct dbus_call_data *call = user_data;
obs_pipewire_data *obs_pw = call->obs_pw;
Expand All @@ -975,8 +976,10 @@ static void on_create_session_response_received_cb(

blog(LOG_INFO, "[pipewire] screencast session created");

g_variant_lookup(result, "session_handle", "s",
&obs_pw->session_handle);
session_handle_variant =
g_variant_lookup_value(result, "session_handle", NULL);
obs_pw->session_handle =
g_variant_dup_string(session_handle_variant, NULL);

select_source(obs_pw);
}
Expand Down

0 comments on commit 5f763cc

Please sign in to comment.