From 05f1c0b9eacf777f562d46457ddb57ca30a834a9 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Tue, 30 Jul 2024 15:01:37 +0200 Subject: [PATCH] mesa: check for enabled extensions for *UID enums Applications might use them without checking if the extension is supported and would run into a NULL pointer deref calling the callbacks. Cc: mesa-stable Part-of: (cherry picked from commit 740cae64a146f46a21e5ddb624a57c30d0e86053) --- .pick_status.json | 2 +- src/mesa/main/get.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index da31b084425..278a6e6e3bf 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -5634,7 +5634,7 @@ "description": "mesa: check for enabled extensions for *UID enums", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 67d9b855c0f..622cb550261 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -2908,20 +2908,28 @@ find_value_indexed(const char *func, GLenum pname, GLuint index, union value *v) /* GL_EXT_external_objects */ case GL_NUM_DEVICE_UUIDS_EXT: + if (!ctx->Extensions.EXT_memory_object && !ctx->Extensions.EXT_semaphore) + goto invalid_enum; v->value_int = 1; return TYPE_INT; case GL_DRIVER_UUID_EXT: + if (!ctx->Extensions.EXT_memory_object && !ctx->Extensions.EXT_semaphore) + goto invalid_enum; if (index >= 1) goto invalid_value; _mesa_get_driver_uuid(ctx, v->value_int_4); return TYPE_INT_4; case GL_DEVICE_UUID_EXT: + if (!ctx->Extensions.EXT_memory_object && !ctx->Extensions.EXT_semaphore) + goto invalid_enum; if (index >= 1) goto invalid_value; _mesa_get_device_uuid(ctx, v->value_int_4); return TYPE_INT_4; /* GL_EXT_memory_object_win32 */ case GL_DEVICE_LUID_EXT: + if (!ctx->Extensions.EXT_memory_object_win32 && !ctx->Extensions.EXT_semaphore_win32) + goto invalid_enum; if (index >= 1) goto invalid_value; _mesa_get_device_luid(ctx, v->value_int_2);