From 35fdb60fe37e75530b973dd842d30f4778bcf28e Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 11 Jan 2025 18:52:28 +0000 Subject: [PATCH] PTY: Check if we have a file descriptor before reading from it Signed-off-by: Michael Tremer --- src/pakfire/pty.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pakfire/pty.c b/src/pakfire/pty.c index 7d76e4b0b..30d6f26fe 100644 --- a/src/pakfire/pty.c +++ b/src/pakfire/pty.c @@ -115,6 +115,10 @@ static int pakfire_pty_store_output(struct pakfire_pty* pty) { struct stat buffer; int r; + // Check if we have a file descriptor + if (pty->stdout.fd < 0) + return -EBADF; + // Stat the buffer r = fstat(pty->stdout.fd, &buffer); if (r < 0) { -- 2.47.3