[vlc-devel] [PATCH 01/12] sftp: fix crash when no directory is specified
Thomas Guillem
thomas at gllm.fr
Tue May 19 10:27:41 CEST 2015
Fallback to "/" directory. Maybe we should go to the HOME directory.
---
modules/access/sftp.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/modules/access/sftp.c b/modules/access/sftp.c
index 43edca1..c564786 100644
--- a/modules/access/sftp.c
+++ b/modules/access/sftp.c
@@ -111,6 +111,7 @@ static int Open( vlc_object_t* p_this )
{
access_t* p_access = (access_t*)p_this;
access_sys_t* p_sys;
+ const char* psz_path;
char* psz_username = NULL;
char* psz_password = NULL;
int i_port;
@@ -129,8 +130,8 @@ static int Open( vlc_object_t* p_this )
p_sys->i_socket = -1;
/* Parse the URL */
- const char* path = p_access->psz_location;
- vlc_UrlParse( &url, path, 0 );
+ vlc_UrlParse( &url, p_access->psz_location, 0 );
+ psz_path = url.psz_path ? url.psz_path : "/";
/* Check for some parameters */
if( EMPTY_STR( url.psz_host ) )
@@ -252,16 +253,16 @@ static int Open( vlc_object_t* p_this )
/* Get some information */
LIBSSH2_SFTP_ATTRIBUTES attributes;
- if( libssh2_sftp_stat( p_sys->sftp_session, url.psz_path, &attributes ) )
+ if( libssh2_sftp_stat( p_sys->sftp_session, psz_path, &attributes ) )
{
- msg_Err( p_access, "Impossible to get information about the remote path %s", url.psz_path );
+ msg_Err( p_access, "Impossible to get information about the remote path %s", psz_path );
goto error;
}
if( !LIBSSH2_SFTP_S_ISDIR( attributes.permissions ))
{
/* Open the given file */
- p_sys->file = libssh2_sftp_open( p_sys->sftp_session, url.psz_path, LIBSSH2_FXF_READ, 0 );
+ p_sys->file = libssh2_sftp_open( p_sys->sftp_session, psz_path, LIBSSH2_FXF_READ, 0 );
p_sys->filesize = attributes.filesize;
ACCESS_SET_CALLBACKS( NULL, Block, Control, Seek );
@@ -269,7 +270,7 @@ static int Open( vlc_object_t* p_this )
else
{
/* Open the given directory */
- p_sys->file = libssh2_sftp_opendir( p_sys->sftp_session, url.psz_path );
+ p_sys->file = libssh2_sftp_opendir( p_sys->sftp_session, psz_path );
p_access->pf_readdir = DirRead;
@@ -284,7 +285,7 @@ static int Open( vlc_object_t* p_this )
if( !p_sys->file )
{
- msg_Err( p_access, "Unable to open the remote path %s", url.psz_path );
+ msg_Err( p_access, "Unable to open the remote path %s", psz_path );
goto error;
}
--
2.1.4
More information about the vlc-devel
mailing list