[vlc-devel] commit: Fixed ftp segfault when no path is specified (close #2019) ( Laurent Aimar )
git version control
git at videolan.org
Tue Sep 9 22:35:40 CEST 2008
vlc | branch: 0.9-bugfix | Laurent Aimar <fenrir at videolan.org> | Tue Sep 9 22:31:09 2008 +0200| [005ae951d61d83dc8d4a8ff99db84bdd8fabc344] | committer: Laurent Aimar
Fixed ftp segfault when no path is specified (close #2019)
(cherry picked from commit 5d0c2971a33c2884a2ffc76a33762c259351a042)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=005ae951d61d83dc8d4a8ff99db84bdd8fabc344
---
modules/access/ftp.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/modules/access/ftp.c b/modules/access/ftp.c
index c3cf705..0b2a410 100644
--- a/modules/access/ftp.c
+++ b/modules/access/ftp.c
@@ -283,7 +283,7 @@ static int Connect( vlc_object_t *p_access, access_sys_t *p_sys )
static int parseURL( vlc_url_t *url, const char *path )
{
if( path == NULL )
- return -1;
+ return VLC_EGENERIC;
/* *** Parse URL and get server addr/port and path *** */
while( *path == '/' )
@@ -292,7 +292,7 @@ static int parseURL( vlc_url_t *url, const char *path )
vlc_UrlParse( url, path, 0 );
if( url->psz_host == NULL || *url->psz_host == '\0' )
- return -1;
+ return VLC_EGENERIC;
if( url->i_port <= 0 )
url->i_port = IPPORT_FTP; /* default port */
@@ -300,10 +300,10 @@ static int parseURL( vlc_url_t *url, const char *path )
/* FTP URLs are relative to user's default directory (RFC1738)
For absolute path use ftp://foo.bar//usr/local/etc/filename */
- if( *url->psz_path == '/' )
+ if( url->psz_path && *url->psz_path == '/' )
url->psz_path++;
- return 0;
+ return VLC_SUCCESS;
}
@@ -328,7 +328,7 @@ static int InOpen( vlc_object_t *p_this )
goto exit_error;
/* get size */
- if( ftp_SendCommand( p_this, p_sys, "SIZE %s", p_sys->url.psz_path ) < 0 ||
+ if( ftp_SendCommand( p_this, p_sys, "SIZE %s", p_sys->url.psz_path ? : "" ) < 0 ||
ftp_ReadCommand( p_this, p_sys, NULL, &psz_arg ) != 2 )
{
msg_Err( p_access, "cannot get file size" );
@@ -762,7 +762,7 @@ static int ftp_StartStream( vlc_object_t *p_access, access_sys_t *p_sys,
/* "1xx" message */
if( ftp_SendCommand( p_access, p_sys, "%s %s",
p_sys->out ? "STOR" : "RETR",
- p_sys->url.psz_path ) < 0 ||
+ p_sys->url.psz_path ?: "" ) < 0 ||
ftp_ReadCommand( p_access, p_sys, &i_answer, NULL ) > 2 )
{
msg_Err( p_access, "cannot retrieve file" );
More information about the vlc-devel
mailing list