]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic/terminal-util: add check for poll timeout in get_default_background_color
authorSam Leonard <sam.leonard@codethink.co.uk>
Tue, 27 Feb 2024 11:12:39 +0000 (11:12 +0000)
committerSam Leonard <sam.leonard@codethink.co.uk>
Wed, 28 Feb 2024 11:50:17 +0000 (11:50 +0000)
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

index 4c1824bc83f52a9fa0393587fde06c55ef2b17e1..aa1cf7cfff71eceff0a19ebb4190811deb05f9b9 100644 (file)
@@ -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);