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




commit c61d89bb03c31fe7138c1bc4120aac7e99cc1b21
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.

 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 a8491ad..5589fca 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]