[gnome-remote-desktop/wip/memcpy-rowstride-fix: 7/7] rdp-pipewire-stream: Correct memcpy size calculation




commit 44b01ac8b5e41b93b53f5539cd5fc2eb7025b3a7
Author: Ray Strode <rstrode redhat com>
Date:   Thu Aug 27 14:04:03 2020 -0400

    rdp-pipewire-stream: Correct memcpy size calculation
    
    The previous commit addressed an issue with memcpy size
    calculation in the vnc backend.  The rdp backend inherited,
    the same bug: a potential crash when the source row stride
    is less than the destination row stride.
    
    This commit introduces the same fix, using the width of the
    row pixel data, only, when performing the copy.
    
    https://gitlab.gnome.org/GNOME/gnome-remote-desktop/-/merge_requests/18

 src/grd-rdp-pipewire-stream.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/src/grd-rdp-pipewire-stream.c b/src/grd-rdp-pipewire-stream.c
index 4fdcf5d..414d3e9 100644
--- a/src/grd-rdp-pipewire-stream.c
+++ b/src/grd-rdp-pipewire-stream.c
@@ -318,18 +318,20 @@ process_buffer (GrdRdpPipeWireStream *stream,
       int src_stride;
       int dst_stride;
       int height;
+      int width;
       int y;
 
       src_stride = buffer->datas[0].chunk->stride;
       dst_stride = grd_session_rdp_get_framebuffer_stride (stream->session_rdp);
       height = stream->spa_format.size.height;
+      width = stream->spa_format.size.width;
 
       frame->data = g_malloc (height * dst_stride);
       for (y = 0; y < height; ++y)
         {
           memcpy (((uint8_t *) frame->data) + y * dst_stride,
                   ((uint8_t *) src_data) + y * src_stride,
-                  dst_stride);
+                  width * 4);
         }
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]