]> git.sesse.net Git - vlc/blobdiff - modules/access/ftp.c
FTP: fix relative file paths (fix #3984)
[vlc] / modules / access / ftp.c
index 0684a3880c527cc51e94ea988b1e8945ce7d5f9a..127ee3572971f1f086605768513d501751019da1 100644 (file)
@@ -303,11 +303,16 @@ static int parseURL( vlc_url_t *url, const char *path )
     if( url->i_port <= 0 )
         url->i_port = IPPORT_FTP; /* default port */
 
+    if( url->psz_path == NULL )
+        return VLC_SUCCESS;
     /* FTP URLs are relative to user's default directory (RFC1738 ยง3.2)
     For absolute path use ftp://foo.bar//usr/local/etc/filename */
     /* FIXME: we should issue a series of CWD, one per slash */
-    if( url->psz_path == NULL )
-        return VLC_SUCCESS;
+    if( url->psz_path )
+    {
+        assert( url->psz_path[0] == '/' );
+        url->psz_path++;
+    }
 
     char *type = strstr( url->psz_path, ";type=" );
     if( type )
@@ -338,7 +343,7 @@ static int InOpen( vlc_object_t *p_this )
     p_sys->out = false;
     p_sys->directory = false;
 
-    if( parseURL( &p_sys->url, p_access->psz_path ) )
+    if( parseURL( &p_sys->url, p_access->psz_location ) )
         goto exit_error;
 
     if( Connect( p_this, p_sys ) )
@@ -595,7 +600,7 @@ static int Control( access_t *p_access, int i_query, va_list args )
         /* */
         case ACCESS_GET_PTS_DELAY:
             pi_64 = (int64_t*)va_arg( args, int64_t * );
-            *pi_64 = (int64_t)var_GetInteger( p_access, "ftp-caching" ) * INT64_C(1000);
+            *pi_64 = var_GetInteger( p_access, "ftp-caching" ) * INT64_C(1000);
             break;
 
         /* */