gfxstream: Fix strict aliasing violations in VkDecoder
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

Test: cvd create --gpu_mode=gfxstream_guest_angle_host_swiftshader

Reviewed-by: Aaron Ruby <aruby@qnx.com>
Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35494>
This commit is contained in:
Jason Macnak 2025-06-11 16:15:18 -07:00 committed by Gurchetan Singh
parent f3e9f0e9a6
commit 3bf5347436
2 changed files with 7 additions and 2 deletions

View file

@ -888,8 +888,12 @@ size_t VkDecoder::Impl::decode(void* buf, size_t len, IOStream* ioStream,
self.cgen.beginBlock() # while loop
self.cgen.stmt("const uint8_t* packet = (const uint8_t *)ptr")
self.cgen.stmt("uint32_t opcode = *(uint32_t *)ptr")
self.cgen.stmt("uint32_t packetLen = *(uint32_t *)(ptr + 4)")
self.cgen.stmt("uint32_t opcode")
self.cgen.stmt("std::memcpy(&opcode, ptr, sizeof(uint32_t))")
self.cgen.line("")
self.cgen.stmt("uint32_t packetLen")
self.cgen.stmt("std::memcpy(&packetLen, ptr + 4, sizeof(uint32_t))")
self.cgen.line("")
self.cgen.line("""
// packetLen should be at least 8 (op code and packet length) and should not be excessively large
if (packetLen < 8 || packetLen > MAX_PACKET_LENGTH) {

View file

@ -560,6 +560,7 @@ class BumpPool;
#include "VulkanDispatch.h"
#include "%s.h"
#include <cstring>
#include <functional>
#include <optional>
#include <unordered_map>