This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

The following commit(s) were added to refs/heads/master by this push:
     new 0b4798f7ab fftools/ffmpeg: disable stdin interaction when fd 0 is 
closed
0b4798f7ab is described below

commit 0b4798f7ab964e288241536175228179acb1410f
Author:     Zhao Zhili <[email protected]>
AuthorDate: Mon Jun 22 20:36:10 2026 +0800
Commit:     Zhao Zhili <[email protected]>
CommitDate: Sun Jun 28 18:26:49 2026 +0000

    fftools/ffmpeg: disable stdin interaction when fd 0 is closed
    
    When the parent process closes stdin before launching ffmpeg, fd 0 is
    left invalid. The first opened input file then reuses fd 0, and the
    read_key() poll in the transcode loop reads from that input instead of
    the terminal, stealing bytes and corrupting the stream.
    
    Fixes #23539
---
 fftools/ffmpeg.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index b394243f59..d38acffbdf 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -216,6 +216,16 @@ void term_init(void)
 #endif
 
 #if HAVE_TERMIOS_H
+    /* A closed fd 0 is later reused by the first opened input file. read_key()
+     * would then read from that input instead of the terminal and corrupt the
+     * stream, so disable interaction when fd 0 is not an open descriptor.
+     */
+    if (stdin_interaction && fcntl(0, F_GETFD) == -1) {
+        av_log(NULL, AV_LOG_WARNING,
+               "fd 0 is not an open file descriptor, stdin interaction 
disabled\n");
+        stdin_interaction = 0;
+    }
+
     if (stdin_interaction) {
         struct termios tty;
         if (tcgetattr (0, &tty) == 0) {

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to