Commit ab3ebee9ea for ffmpeg
commit ab3ebee9ea744f136fa547ef355aa9f2df919bde
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Thu Oct 15 14:39:09 2026 +0200
avformat/ftp: accept reply code 125 for MLSD
A server that finds the data connection open when it receives MLSD
replies with 125 instead of 150, which left ftp_status() waiting for
a further reply until the server dropped the control connection.
Reply code 125 is accepted for RETR and STOR already.
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 67eecc5661..07dd68d7e9 100644
--- a/libavformat/ftp.c
+++ b/libavformat/ftp.c
@@ -513,9 +513,10 @@ static int ftp_set_dir(FTPContext *s)
static int ftp_list_mlsd(FTPContext *s)
{
static const char *command = "MLSD\r\n";
- static const int mlsd_codes[] = {150, 500, 0}; /* 500 is incorrect code */
+ static const int mlsd_codes[] = {150, 125, 500, 0}; /* 500 is incorrect code */
+ int resp_code = ftp_send_command(s, command, mlsd_codes, NULL);
- if (ftp_send_command(s, command, mlsd_codes, NULL) != 150)
+ if (resp_code != 150 && resp_code != 125)
return AVERROR(ENOSYS);
s->listing_method = MLSD;
return 0;