From 9924d3c595958982b331c7e5f326bb3a4c1c7db6 Mon Sep 17 00:00:00 2001 From: Sam Leonard Date: Tue, 27 Feb 2024 11:12:39 +0000 Subject: [PATCH] basic/terminal-util: add check for poll timeout in get_default_background_color Currently the return value 0 is not checked for, this indicates a timeout and should be handled to prevent doing a blocking read on a file descriptor with no data ready. --- src/basic/terminal-util.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index 4c1824bc83..aa1cf7cfff 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -1744,6 +1744,10 @@ int get_default_background_color(double *ret_red, double *ret_green, double *ret r = fd_wait_for_event(STDIN_FILENO, POLLIN, usec_sub_unsigned(end, n)); if (r < 0) goto finish; + if (r == 0) { + r = -EOPNOTSUPP; + goto finish; + } ssize_t l; l = read(STDIN_FILENO, buf, sizeof(buf) - buf_full);