1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:37:46 +00:00

LibVirtGPU: Add length verification to append_create_shader()

This commit is contained in:
Stephan Unverwerth 2022-12-21 16:01:34 +01:00 committed by Andreas Kling
parent 140338670a
commit 0993aba321

View file

@ -273,6 +273,8 @@ void CommandBufferBuilder::append_set_constant_buffer(Vector<float> const& const
void CommandBufferBuilder::append_create_shader(Protocol::ObjectHandle handle, Gallium::ShaderType shader_type, StringView shader_data) void CommandBufferBuilder::append_create_shader(Protocol::ObjectHandle handle, Gallium::ShaderType shader_type, StringView shader_data)
{ {
size_t shader_len = shader_data.length() + 1; // Need to remember to copy null terminator as well if needed size_t shader_len = shader_data.length() + 1; // Need to remember to copy null terminator as well if needed
VERIFY(shader_len <= NumericLimits<u32>::max());
CommandBuilder builder(m_buffer, Protocol::VirGLCommand::CREATE_OBJECT, Protocol::ObjectType::SHADER); CommandBuilder builder(m_buffer, Protocol::VirGLCommand::CREATE_OBJECT, Protocol::ObjectType::SHADER);
builder.appendu32(handle.value()); // VIRGL_OBJ_CREATE_HANDLE builder.appendu32(handle.value()); // VIRGL_OBJ_CREATE_HANDLE
builder.appendu32(to_underlying(shader_type)); builder.appendu32(to_underlying(shader_type));