From 45f34b7dfef3f77ee941bc7fc899b05497869a6e Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 15 Oct 2026 14:40:25 +0200 Subject: [PATCH] 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 --- libavformat/ftp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; }