From cdc2e439bab494ccfcef423ece1f066fab17683c Mon Sep 17 00:00:00 2001 From: Daniel Riehm <[email protected]> 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 <[email protected]> --- 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
_______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
