diff options
author | Olivier Fourdan <ofourdan@redhat.com> | 2024-04-23 11:04:13 +0200 |
---|---|---|
committer | Olivier Fourdan <ofourdan@redhat.com> | 2024-05-02 10:16:44 +0200 |
commit | aa17d7eba6c7abda436af62663d00d63ef282f61 (patch) | |
tree | f8f288561bff5c632d1c3debb1fcaac9e8b19222 | |
parent | 158246a0afac943cdf30adf06caf73279f025187 (diff) |
xwayland: Check for duplicate output names
Even though the name provided by either xdg-output or wl_output are
guaranteed to be unique, that might not be the case with output names
between different protocols, such as the one offered for DRM lease.
To avoid running into name conflicts, check that no other existing
output of the same name exists prior to changing the output name.
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
(cherry picked from commit d36f66f15d367c86cb93605caa2a6520a2fcde46)
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1494>
-rw-r--r-- | hw/xwayland/xwayland-output.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c index f318cd57b..f75591500 100644 --- a/hw/xwayland/xwayland-output.c +++ b/hw/xwayland/xwayland-output.c @@ -685,6 +685,9 @@ void xwl_output_set_name(struct xwl_output *xwl_output, const char *name) { struct xwl_screen *xwl_screen = xwl_output->xwl_screen; + rrScrPrivPtr pScrPriv; + RRLeasePtr lease; + int i; if (xwl_output->randr_output == NULL) return; /* rootful */ @@ -695,6 +698,24 @@ xwl_output_set_name(struct xwl_output *xwl_output, const char *name) return; } + /* Check for duplicate names to be safe */ + pScrPriv = rrGetScrPriv(xwl_screen->screen); + for (i = 0; i < pScrPriv->numOutputs; i++) { + if (!strcmp(name, pScrPriv->outputs[i]->name)) { + ErrorF("An output named '%s' already exists", name); + return; + } + } + /* And leases' names as well */ + xorg_list_for_each_entry(lease, &pScrPriv->leases, list) { + for (i = 0; i < lease->numOutputs; i++) { + if (!strcmp(name, pScrPriv->outputs[i]->name)) { + ErrorF("A lease output named '%s' already exists", name); + return; + } + } + } + snprintf(xwl_output->randr_output->name, MAX_OUTPUT_NAME, "%s", name); xwl_output->randr_output->nameLength = strlen(xwl_output->randr_output->name); |