]> git.sesse.net Git - ffmpeg/commitdiff
avformat/ftp: Support response code 125 for STOR and RETR commands
authorRaymond Hilseth <rhi@vizrt.com>
Thu, 7 Jan 2016 09:38:06 +0000 (10:38 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Mon, 7 Mar 2016 01:13:13 +0000 (02:13 +0100)
This fixes a problem where ffmpeg would hang if there is already an open
data connection, and the server sends a 125 response code in reply to a
STOR or RETR command.

Signed-off-by: Raymond Hilseth <rhi@vizrt.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/ftp.c

index 890930c4f04e70b7ce3f7a396312a63592565c86..b9fee2450e7e4a2cf74f9de1ed91d4fd97daa041 100644 (file)
@@ -401,10 +401,12 @@ static int ftp_file_size(FTPContext *s)
 static int ftp_retrieve(FTPContext *s)
 {
     char command[CONTROL_BUFFER_SIZE];
-    static const int retr_codes[] = {150, 0};
+    static const int retr_codes[] = {150, 125, 0};
+    int resp_code;
 
     snprintf(command, sizeof(command), "RETR %s\r\n", s->path);
-    if (ftp_send_command(s, command, retr_codes, NULL) != 150)
+    resp_code = ftp_send_command(s, command, retr_codes, NULL);
+    if (resp_code != 125 && resp_code != 150)
         return AVERROR(EIO);
 
     s->state = DOWNLOADING;
@@ -415,10 +417,12 @@ static int ftp_retrieve(FTPContext *s)
 static int ftp_store(FTPContext *s)
 {
     char command[CONTROL_BUFFER_SIZE];
-    static const int stor_codes[] = {150, 0};
+    static const int stor_codes[] = {150, 125, 0};
+    int resp_code;
 
     snprintf(command, sizeof(command), "STOR %s\r\n", s->path);
-    if (ftp_send_command(s, command, stor_codes, NULL) != 150)
+    resp_code = ftp_send_command(s, command, stor_codes, NULL);
+    if (resp_code != 125 && resp_code != 150)
         return AVERROR(EIO);
 
     s->state = UPLOADING;