[vlc-commits] ftp: fix data reception (fixes #18803)

Rémi Denis-Courmont git at videolan.org
Tue Sep 12 19:17:19 CEST 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Sep 12 20:16:14 2017 +0300| [e15084442ce173e81bfe76274a4b04396d7edf03] | committer: Rémi Denis-Courmont

ftp: fix data reception (fixes #18803)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e15084442ce173e81bfe76274a4b04396d7edf03
---

 modules/access/ftp.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/modules/access/ftp.c b/modules/access/ftp.c
index 0e36161c1e..edffc597df 100644
--- a/modules/access/ftp.c
+++ b/modules/access/ftp.c
@@ -301,6 +301,14 @@ static int ftp_RecvCommand( vlc_object_t *obj, access_sys_t *sys,
     return ftp_RecvAnswer( obj, sys, codep, strp, DummyLine, NULL );
 }
 
+static int ftp_RecvCommandInit( vlc_object_t *obj, access_sys_t *sys )
+{
+    int val = ftp_RecvReply( obj, sys, NULL, DummyLine, NULL );
+    if( val >= 0 )
+        val /= 100;
+    return val;
+}
+
 static int ftp_StartStream( vlc_object_t *, access_sys_t *, uint64_t, bool );
 static int ftp_StopStream ( vlc_object_t *, access_sys_t * );
 
@@ -1124,13 +1132,13 @@ static int ftp_StartStream( vlc_object_t *p_access, access_sys_t *p_sys,
     {
         if( p_sys->features.b_mlst &&
             ftp_SendCommand( p_access, p_sys, "MLSD" ) >= 0 &&
-            ftp_RecvCommand( p_access, p_sys, NULL, NULL ) <= 2 )
+            ftp_RecvCommandInit( p_access, p_sys ) == 1 )
         {
             msg_Dbg( p_access, "Using MLST extension to list" );
         }
         else
         if( ftp_SendCommand( p_access, p_sys, "NLST" ) < 0 ||
-            ftp_RecvCommand( p_access, p_sys, NULL, NULL ) > 2 )
+            ftp_RecvCommandInit( p_access, p_sys ) == 1 )
         {
             msg_Err( p_access, "cannot list directory contents" );
             return VLC_EGENERIC;
@@ -1143,7 +1151,7 @@ static int ftp_StartStream( vlc_object_t *p_access, access_sys_t *p_sys,
         if( ftp_SendCommand( p_access, p_sys, "%s %s",
                              p_sys->out ? "STOR" : "RETR",
                              p_sys->url.psz_path ) < 0
-         || ftp_RecvCommand( p_access, p_sys, &i_answer, NULL ) > 2 )
+         || ftp_RecvCommandInit( p_access, p_sys ) != 1 )
         {
             msg_Err( p_access, "cannot retrieve file" );
             return VLC_EGENERIC;



More information about the vlc-commits mailing list