Commit 6962020b authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

module: Make sure we can escape ':' correctly.

parent 242a2d12
...@@ -906,59 +906,99 @@ void module_PutConfig( module_config_t *config ) ...@@ -906,59 +906,99 @@ void module_PutConfig( module_config_t *config )
* Following functions are local. * Following functions are local.
*****************************************************************************/ *****************************************************************************/
/*****************************************************************************
* copy_next_paths_token: from a PATH_SEP_CHAR (a ':' or a ';') separated paths
* return first path.
*****************************************************************************/
static char * copy_next_paths_token( char * paths, char ** remaining_paths )
{
char * path;
int i;
bool escaped = false;
assert( paths );
/* Alloc a buffer to store the path */
path = malloc( strlen( paths ) );
if( !path ) return NULL;
/* Look for PATH_SEP_CHAR (a ':' or a ';') */
for( i = 0; paths[i]; i++ ) {
/* Take care of \\ and \: or \; escapement */
if( escaped ) {
escaped = false;
path[i] = paths[i];
}
else if( paths[i] == '\\' )
escaped = true;
else if( paths[i] == PATH_SEP_CHAR )
break;
else
path[i] = paths[i];
}
/* Return the remaining paths */
if( remaining_paths ) {
*remaining_paths = paths[i] ? &paths[i]+1 : NULL;
}
return path;
}
/***************************************************************************** /*****************************************************************************
* AllocateAllPlugins: load all plugin modules we can find. * AllocateAllPlugins: load all plugin modules we can find.
*****************************************************************************/ *****************************************************************************/
#ifdef HAVE_DYNAMIC_PLUGINS #ifdef HAVE_DYNAMIC_PLUGINS
static void AllocateAllPlugins( vlc_object_t *p_this ) static void AllocateAllPlugins( vlc_object_t *p_this )
{ {
char *path, *ppsz_path, *psz_iter; char *paths, *path, *paths_iter;
#if defined( WIN32 ) || defined( UNDER_CE ) #if defined( WIN32 ) || defined( UNDER_CE )
const char * extra_path = ""; const char * extra_path = "";
#else #else
const char * extra_path = PLUGIN_PATH; const char * extra_path = ":" PLUGIN_PATH;
#endif #endif
/* If the user provided a plugin path, we add it to the list */ /* If the user provided a plugin path, we add it to the list */
char * userpath = config_GetPsz( p_this, "plugin-path" ); char * userpaths = config_GetPsz( p_this, "plugin-path" );
bool end = false;
if( asprintf( &path, "modules%s:plugins:%s", extra_path, userpath ) < 0 ) if( asprintf( &paths, "modules%s:plugins:%s", extra_path, userpaths ) < 0 )
{ {
msg_Err( p_this, "Not enough memory" ); msg_Err( p_this, "Not enough memory" );
free( userpath ); free( userpaths );
return; return;
} }
/* Free plugin-path */ /* Free plugin-path */
free( userpath ); free( userpaths );
for( ppsz_path = path; !end; ) for( paths_iter = paths; paths_iter; )
{ {
char *psz_fullpath; char *psz_fullpath;
/* Look for PATH_SEP_CHAR (a ':' or a ';') */ path = copy_next_paths_token( paths_iter, &paths_iter );
for( psz_iter = ppsz_path; *psz_iter && *psz_iter != PATH_SEP_CHAR; psz_iter++ ); if( !path )
if( !*psz_iter ) end = true; {
else *psz_iter = 0; msg_Err( p_this, "Not enough memory" );
return;
}
#if defined( SYS_BEOS ) || defined( __APPLE__ ) || defined( WIN32 ) #if defined( SYS_BEOS ) || defined( __APPLE__ ) || defined( WIN32 )
/* Handle relative as well as absolute paths */ /* Handle relative as well as absolute paths */
#ifdef WIN32 #ifdef WIN32
if( ppsz_path[0] != '\\' && ppsz_path[0] != '/' && ppsz_path[0] != ':' ) if( path[0] != '\\' && path[0] != '/' && path[0] != ':' )
#else #else
if( ppsz_path[0] != '/' ) if( path[0] != '/' )
#endif #endif
{ {
if( 0>= asprintf( &psz_fullpath, "%s"DIR_SEP"%s", if( 0>= asprintf( &psz_fullpath, "%s"DIR_SEP"%s",
vlc_global()->psz_vlcpath, ppsz_path) ) vlc_global()->psz_vlcpath, path) )
psz_fullpath = NULL; psz_fullpath = NULL;
} }
else else
#endif #endif
psz_fullpath = strdup( ppsz_path ); psz_fullpath = strdup( path );
if( psz_fullpath == NULL ) if( psz_fullpath == NULL )
continue; continue;
...@@ -969,11 +1009,10 @@ static void AllocateAllPlugins( vlc_object_t *p_this ) ...@@ -969,11 +1009,10 @@ static void AllocateAllPlugins( vlc_object_t *p_this )
AllocatePluginDir( p_this, psz_fullpath, 5 ); AllocatePluginDir( p_this, psz_fullpath, 5 );
free( psz_fullpath ); free( psz_fullpath );
if( !end ) ppsz_path = psz_iter + 1; free( path );
} }
/* Free plugin-path */ free( paths );
free( path );
} }
/***************************************************************************** /*****************************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment