]> git.ipfire.org Git - pakfire.git/commitdiff
PTY: Check if we have a file descriptor before reading from it
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 11 Jan 2025 18:52:28 +0000 (18:52 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 11 Jan 2025 18:52:28 +0000 (18:52 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/pty.c

index 7d76e4b0b691a215702931c9ee83442c672a50f2..30d6f26fe7e111b56c2cfc39b06390a0f85c48e3 100644 (file)
@@ -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) {