From 15f2f6642fb5020c1b69e5424a8463569ea6a3e9 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Mon, 5 Jun 2023 11:51:06 +0200 Subject: gamma-control: Read ramps using pread read advances the file description offset, and requires the client to ensure that it is reset appropriately before the next gamma ramp submission. As there is no event to indicate that wlroots finished processing the new gamma ramp, this can result in a race between the client seeking in the file and wlroots reading its content. Use pread with a fixed offset instead. Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3655 --- types/wlr_gamma_control_v1.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/wlr_gamma_control_v1.c b/types/wlr_gamma_control_v1.c index b38408d3..1b771494 100644 --- a/types/wlr_gamma_control_v1.c +++ b/types/wlr_gamma_control_v1.c @@ -1,3 +1,4 @@ +#define _POSIX_C_SOURCE 200809L #include #include #include @@ -119,7 +120,7 @@ static void gamma_control_handle_set_gamma(struct wl_client *client, goto error_fd; } - ssize_t n_read = read(fd, table, table_size); + ssize_t n_read = pread(fd, table, table_size, 0); if (n_read < 0) { wlr_log_errno(WLR_ERROR, "failed to read gamma table"); gamma_control_send_failed(gamma_control); -- cgit v1.2.3