st/va: Fix potential buffer overread
authorDrew Davenport <ddavenport@chromium.org>
Tue, 24 Apr 2018 23:01:32 +0000 (17:01 -0600)
committerLeo Liu <leo.liu@amd.com>
Thu, 26 Apr 2018 15:16:05 +0000 (11:16 -0400)
VASurfaceAttribExternalBuffers.pitches is indexed by
plane. Current implementation only supports single plane layout.

Reviewed-by: Kristian H. Kristensen <hoegsberg@chromium.org>
Reviewed-by: Leo Liu <leo.liu@amd.com>
src/gallium/state_trackers/va/surface.c

index 860413694445f5bf5ff7801bc40b37c36667c2c6..6fe21b89e5891d0e510d0f247138fd8639398dc0 100644 (file)
@@ -574,7 +574,7 @@ suface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface,
    memset(&whandle, 0, sizeof(struct winsys_handle));
    whandle.type = DRM_API_HANDLE_TYPE_FD;
    whandle.handle = memory_attibute->buffers[index];
-   whandle.stride = memory_attibute->pitches[index];
+   whandle.stride = memory_attibute->pitches[0];
 
    resource = pscreen->resource_from_handle(pscreen, &res_templ, &whandle,
                                             PIPE_HANDLE_USAGE_READ_WRITE);