[vlc-devel] [PATCH] access: ftp: fix EPSV activation answer handling

Francois Cartegnie fcvlcdev at free.fr
Thu Jul 2 16:15:17 CEST 2020


RFC 2428
The response code for entering passive mode using
an extended address MUST be 229.

Some servers are broken and do reply with
PASV response syntax and code.  This is unnoticed
by other clients as they do handle response code.
---
 modules/access/ftp.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/modules/access/ftp.c b/modules/access/ftp.c
index 0118ec7d9e..c491d28323 100644
--- a/modules/access/ftp.c
+++ b/modules/access/ftp.c
@@ -1079,7 +1079,7 @@ static int ftp_StartStream( vlc_object_t *p_access, access_sys_t *p_sys,
         return VLC_EGENERIC;
     }
 
-    if( *psz_ip )
+    if( i_answer == 229 && *psz_ip )
     {
         if( sscanf( psz_parser, "(%*3c%u", &i_port ) < 1 )
         {
@@ -1088,7 +1088,7 @@ static int ftp_StartStream( vlc_object_t *p_access, access_sys_t *p_sys,
             return VLC_EGENERIC;
         }
     }
-    else
+    else if( i_answer == 227 )
     {
         unsigned a1, a2, a3, a4, p1, p2;
 
@@ -1105,6 +1105,12 @@ static int ftp_StartStream( vlc_object_t *p_access, access_sys_t *p_sys,
         psz_ip = psz_ipv4;
         i_port = (p1 << 8) | p2;
     }
+    else
+    {
+        free( psz_arg );
+        msg_Err( p_access, "invalid response code %d", i_answer );
+        return VLC_EGENERIC;
+    }
     free( psz_arg );
 
     msg_Dbg( p_access, "ip:%s port:%d", psz_ip, i_port );
-- 
2.25.4



More information about the vlc-devel mailing list