Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avformat/aviobuf: ensure EAGAIN is not interpreted as EOF
@ 2025-11-17 22:21 Daniel Riehm via ffmpeg-devel
  2025-11-18  0:36 ` [FFmpeg-devel] " Timo Rothenpieler via ffmpeg-devel
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Riehm via ffmpeg-devel @ 2025-11-17 22:21 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Daniel Riehm

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: 0001-avformat-aviobuf-ensure-EAGAIN-is-not-interpreted-as.patch --]
[-- Type: text/x-patch, Size: 2482 bytes --]

From cdc2e439bab494ccfcef423ece1f066fab17683c Mon Sep 17 00:00:00 2001
From: Daniel Riehm <daniel.riehm@kitware.com>
Date: Mon, 17 Nov 2025 15:25:42 -0600
Subject: [PATCH] avformat/aviobuf: ensure EAGAIN is not interpreted as EOF

When AVIO_FLAG_NONBLOCK is enabled, I/O operations may
return AVERROR(EAGAIN). avio_read() should pass along
this error without marking EOF, as for other errors.

Signed-off-by: Daniel Riehm <daniel.riehm@kitware.com>
---
 libavformat/aviobuf.c | 7 +++++--
 libavformat/format.c  | 5 +++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 9beac8bcd5..c0ecf0e3ac 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -554,7 +554,8 @@ static void fill_buffer(AVIOContext *s)
            be done without rereading data */
         s->eof_reached = 1;
     } else if (len < 0) {
-        s->eof_reached = 1;
+        if (len != AVERROR(EAGAIN))
+            s->eof_reached = 1;
         s->error= len;
     } else {
         s->pos += len;
@@ -616,6 +617,7 @@ int avio_read(AVIOContext *s, unsigned char *buf, int size)
 {
     int len, size1;
 
+    s->error = 0;
     size1 = size;
     while (size > 0) {
         len = FFMIN(s->buf_end - s->buf_ptr, size);
@@ -629,7 +631,8 @@ int avio_read(AVIOContext *s, unsigned char *buf, int size)
                     s->eof_reached = 1;
                     break;
                 } else if (len < 0) {
-                    s->eof_reached = 1;
+                    if (len != AVERROR(EAGAIN))
+                        s->eof_reached = 1;
                     s->error= len;
                     break;
                 } else {
diff --git a/libavformat/format.c b/libavformat/format.c
index 516925e7e4..c78acdbcbf 100644
--- a/libavformat/format.c
+++ b/libavformat/format.c
@@ -291,8 +291,9 @@ int av_probe_input_buffer2(AVIOContext *pb, const AVInputFormat **fmt,
         /* Read probe data. */
         if ((ret = av_reallocp(&buf, probe_size + AVPROBE_PADDING_SIZE)) < 0)
             goto fail;
-        if ((ret = avio_read(pb, buf + buf_offset,
-                             probe_size - buf_offset)) < 0) {
+        while ((ret = avio_read(pb, buf + buf_offset,
+                                probe_size - buf_offset)) == AVERROR(EAGAIN));
+        if (ret < 0) {
             /* Fail if error was not end of file, otherwise, lower score. */
             if (ret != AVERROR_EOF)
                 goto fail;
-- 
2.34.1


[-- Attachment #3: Type: text/plain, Size: 163 bytes --]

_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-11-18  0:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-17 22:21 [FFmpeg-devel] [PATCH] avformat/aviobuf: ensure EAGAIN is not interpreted as EOF Daniel Riehm via ffmpeg-devel
2025-11-18  0:36 ` [FFmpeg-devel] " Timo Rothenpieler via ffmpeg-devel

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git