aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-11-16 22:55:54 +0100
committerSimon Zeni <simon@bl4ckb0ne.ca>2021-11-17 16:12:59 +0000
commit9a4e1095cad154b7f8ce41cedbfb1e9a7e137d66 (patch)
tree95ed10cb7840ec1cf525e83096cae3b37450be67
parent8274c85d21df4c790b46666f4383731c89352480 (diff)
linux-dmabuf-v1: properly validate flags
We were send a protocol error if INTERLACED or BOTTOM_FIRST was set. This is incorrect for the zwp_linux_dmabuf_params.create code-path because this kills the client without allowing it to gracefully handle the error. We should only send a protocol error if the client provides a bit not listed in the protocol definition.
-rw-r--r--types/wlr_linux_dmabuf_v1.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/types/wlr_linux_dmabuf_v1.c b/types/wlr_linux_dmabuf_v1.c
index 7b08b350..b111a721 100644
--- a/types/wlr_linux_dmabuf_v1.c
+++ b/types/wlr_linux_dmabuf_v1.c
@@ -204,6 +204,17 @@ static void params_create_common(struct wl_resource *params_resource,
goto err_out;
}
+ /* reject unknown flags */
+ uint32_t all_flags = ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT |
+ ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_INTERLACED |
+ ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_BOTTOM_FIRST;
+ if (flags & ~all_flags) {
+ wl_resource_post_error(params_resource,
+ ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_FORMAT,
+ "Unknown dmabuf flags %"PRIu32, flags);
+ goto err_out;
+ }
+
attribs.width = width;
attribs.height = height;
attribs.format = format;
@@ -265,14 +276,6 @@ static void params_create_common(struct wl_resource *params_resource,
}
}
- /* reject unknown flags */
- if (attribs.flags & ~ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT) {
- wl_resource_post_error(params_resource,
- ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_FORMAT,
- "Unknown dmabuf flags %"PRIu32, attribs.flags);
- goto err_out;
- }
-
/* Check if dmabuf is usable */
if (!check_import_dmabuf(linux_dmabuf, &attribs)) {
goto err_failed;