Commit 45f34b7dfe for ffmpeg
commit 45f34b7dfef3f77ee941bc7fc899b05497869a6e
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Thu Oct 15 14:40:25 2026 +0200
avformat/ftp: end a directory listing when the data connection ends
ffurl_read() reports the end of the data with AVERROR_EOF, which
ftp_read_dir() passed on as an error instead of ending the listing.
Fixes: avio_list_dir on a directory served by pyftpdlib 2.0.1
Assisted-by: Claude
diff --git a/libavformat/ftp.c b/libavformat/ftp.c
index 07dd68d7e9..44adef7eab 100644
--- a/libavformat/ftp.c
+++ b/libavformat/ftp.c
@@ -1071,9 +1071,9 @@ static int ftp_read_dir(URLContext *h, AVIODirEntry **next)
if (s->dir_buffer_size)
memmove(s->dir_buffer, start, s->dir_buffer_size);
ret = ffurl_read(s->conn_data, s->dir_buffer + s->dir_buffer_size, DIR_BUFFER_SIZE - (s->dir_buffer_size + 1));
- if (ret < 0)
+ if (ret < 0 && ret != AVERROR_EOF)
return ret;
- if (!ret) {
+ if (ret <= 0) {
*next = NULL;
return 0;
}