xserver: Branch 'master' - 2 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Dec 4 07:37:30 UTC 2023


 hw/xwayland/xwayland-output.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

New commits:
commit 83453fb51e20c9763f437ca3c3defb2956682686
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Fri Dec 1 15:23:27 2023 +0100

    xwayland: Use the right nameLength by default
    
    When creating the output with the default "XWAYLAND<n>" name, we use
    the MAX_OUTPUT_NAME value to allocate a lot more memory than necessary
    to accommodate for future output names once they get updated, but by
    doing so, we also send XRandR way too much (zeroed) data since the
    "nameLength" value is (purposely) set too big.
    
    So, instead, let's just update the name after creating the RR output,
    this way we set both the name and nameLength to their correct values
    while keeping the initial large allocation.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Fixes: 3c07a01c42 - xwayland: Use xdg-output name for XRandR
    Reviewed-by: Simon Ser <contact at emersion.fr>

diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
index 5884402d1..cf99c6e84 100644
--- a/hw/xwayland/xwayland-output.c
+++ b/hw/xwayland/xwayland-output.c
@@ -847,9 +847,6 @@ xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id,
     xwl_output->xwl_screen = xwl_screen;
 
     if (with_xrandr) {
-        snprintf(name, MAX_OUTPUT_NAME, "XWAYLAND%d",
-                 xwl_screen_get_next_output_serial(xwl_screen));
-
         xwl_output->randr_crtc = RRCrtcCreate(xwl_screen->screen, xwl_output);
         if (!xwl_output->randr_crtc) {
             ErrorF("Failed creating RandR CRTC\n");
@@ -857,12 +854,17 @@ xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id,
         }
         RRCrtcSetRotations (xwl_output->randr_crtc, ALL_ROTATIONS);
 
+        /* Allocate MAX_OUTPUT_NAME data for the output name, all filled with zeros */
         xwl_output->randr_output = RROutputCreate(xwl_screen->screen, name,
                                                   MAX_OUTPUT_NAME, xwl_output);
         if (!xwl_output->randr_output) {
             ErrorF("Failed creating RandR Output\n");
             goto err;
         }
+        /* Set the default output name to a sensible value */
+        snprintf(name, MAX_OUTPUT_NAME, "XWAYLAND%d",
+                 xwl_screen_get_next_output_serial(xwl_screen));
+        xwl_output_set_name(xwl_output, name);
         xwl_output_set_emulated(xwl_output);
 
         RRCrtcGammaSetSize(xwl_output->randr_crtc, 256);
commit 0e314afef62b1d03c67273a8479bfdf8fe9f2573
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Fri Dec 1 14:12:21 2023 +0100

    xwayland: Update output nameLength
    
    At creation, Xwayland uses a generic output name ("XWAYLAND0", etc.) for
    the XRandR outputs, and later, once the name is known from the Wayland
    protocols, updates the output names using the actual names from the
    Wayland compositor.
    
    However, when doing so, it simply updates the string, the "nameLength"
    isn't updated, so the name passed to the clients might either end up
    being truncated or contain portions of the previous (initial) output
    name.
    
    Note, this is using a fixed size buffer initialized with zeros, so this
    cannot leak any data other than the previous output name, so this is
    mainly a cosmetic issue.
    
    Update the output's "nameLength" when updating the output name.
    
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Fixes: 3c07a01c42 - xwayland: Use xdg-output name for XRandR
    Reviewed-by: Simon Ser <contact at emersion.fr>

diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
index f26fb5a4f..5884402d1 100644
--- a/hw/xwayland/xwayland-output.c
+++ b/hw/xwayland/xwayland-output.c
@@ -683,6 +683,7 @@ xwl_output_set_name(struct xwl_output *xwl_output, const char *name)
     }
 
     snprintf(xwl_output->randr_output->name, MAX_OUTPUT_NAME, "%s", name);
+    xwl_output->randr_output->nameLength = strlen(xwl_output->randr_output->name);
 }
 
 static void


More information about the xorg-commit mailing list