From: Daniel Riehm via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Daniel Riehm <daniel.riehm@kitware.com>
Subject: [FFmpeg-devel] [PATCH] avformat/aviobuf: ensure EAGAIN is not interpreted as EOF
Date: Mon, 17 Nov 2025 16:21:02 -0600
Message-ID: <CAHWB-xqy78S2=avVKzU0yFjHFg7x6q6K1V7q7DitjH2-k0ToRw@mail.gmail.com> (raw)
[-- 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
next reply other threads:[~2025-11-17 22:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-17 22:21 Daniel Riehm via ffmpeg-devel [this message]
2025-11-18 0:36 ` [FFmpeg-devel] " Timo Rothenpieler via ffmpeg-devel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAHWB-xqy78S2=avVKzU0yFjHFg7x6q6K1V7q7DitjH2-k0ToRw@mail.gmail.com' \
--to=ffmpeg-devel@ffmpeg.org \
--cc=daniel.riehm@kitware.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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