mirror of
https://code.videolan.org/videolan/vlc
synced 2024-08-27 04:21:53 +02:00
Renamed input_item_AddOpt to input_item_AddOption.
This will force people to use VLC_INPUT_OPTION_TRUSTED flag when they need it and ease security review. This commit has no functionnal/security changes.
This commit is contained in:
parent
de2fd33218
commit
36edd71568
@ -114,14 +114,21 @@ VLC_EXPORT( void, input_item_SetName, ( input_item_t *p_item, const char *psz_na
|
||||
VLC_EXPORT( void, input_item_AddSubItem, ( input_item_t *p_parent, input_item_t *p_child ) );
|
||||
|
||||
|
||||
/* Flags handled past input_item_AddOpt() */
|
||||
#define VLC_INPUT_OPTION_TRUSTED 0x2
|
||||
/**
|
||||
* Option flags
|
||||
*/
|
||||
enum input_item_option_e
|
||||
{
|
||||
VLC_INPUT_OPTION_TRUSTED = 0x2,
|
||||
VLC_INPUT_OPTION_UNIQUE = 0x100,
|
||||
};
|
||||
|
||||
/* Flags handled within input_item_AddOpt() */
|
||||
#define VLC_INPUT_OPTION_UNIQUE 0x100
|
||||
/**
|
||||
* This function allows to add an option to an existing input_item_t.
|
||||
*/
|
||||
VLC_EXPORT( int, input_item_AddOption, (input_item_t *, const char *, unsigned i_flags ) );
|
||||
|
||||
VLC_EXPORT( int, input_item_AddOpt, ( input_item_t *, const char *str, unsigned flags ) );
|
||||
VLC_EXPORT( int, input_item_AddOption, (input_item_t *, const char * ) );
|
||||
/* */
|
||||
VLC_EXPORT( bool, input_item_HasErrorWhenReading, ( input_item_t * ) );
|
||||
VLC_EXPORT( void, input_item_SetMeta, ( input_item_t *, vlc_meta_type_t meta_type, const char *psz_val ));
|
||||
VLC_EXPORT( bool, input_item_MetaMatch, ( input_item_t *p_i, vlc_meta_type_t meta_type, const char *psz ) );
|
||||
|
@ -440,9 +440,9 @@ static int GetTracks( access_t *p_access, input_item_t *p_current )
|
||||
psz_uri, psz_name, 0, NULL, -1,
|
||||
ITEM_TYPE_DISC );
|
||||
input_item_CopyOptions( p_current, p_input_item );
|
||||
input_item_AddOption( p_input_item, psz_first );
|
||||
input_item_AddOption( p_input_item, psz_last );
|
||||
input_item_AddOption( p_input_item, psz_opt );
|
||||
input_item_AddOption( p_input_item, psz_first, VLC_INPUT_OPTION_TRUSTED );
|
||||
input_item_AddOption( p_input_item, psz_last, VLC_INPUT_OPTION_TRUSTED );
|
||||
input_item_AddOption( p_input_item, psz_opt, VLC_INPUT_OPTION_TRUSTED );
|
||||
const mtime_t i_duration = (int64_t)( p_sys->p_sectors[i+1] - p_sys->p_sectors[i] ) *
|
||||
CDDA_DATA_SIZE * 1000000 / 44100 / 2 / 2;
|
||||
input_item_SetDuration( p_input_item, i_duration );
|
||||
|
@ -897,7 +897,7 @@ input_item_t *MRLParse( intf_thread_t *p_intf, const char *mrl,
|
||||
{
|
||||
s_temp = s_mrl + strlen( s_mrl );
|
||||
}
|
||||
input_item_AddOption( p_input, s_mrl );
|
||||
input_item_AddOption( p_input, s_mrl, VLC_INPUT_OPTION_TRUSTED );
|
||||
s_mrl = s_temp;
|
||||
}
|
||||
|
||||
|
@ -2245,7 +2245,7 @@ static input_item_t *parse_MRL( intf_thread_t *p_intf, char *psz_mrl )
|
||||
p_item = input_item_New( p_intf, psz_item_mrl, NULL );
|
||||
for( i = 0; i < i_options; i++ )
|
||||
{
|
||||
input_item_AddOption( p_item, ppsz_options[i] );
|
||||
input_item_AddOption( p_item, ppsz_options[i], VLC_INPUT_OPTION_TRUSTED );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ static int Demux( demux_t *p_demux )
|
||||
for( i = 0; i< i_options; i++ )
|
||||
{
|
||||
EnsureUTF8( ppsz_options[i] );
|
||||
input_item_AddOption( p_input, ppsz_options[i] );
|
||||
input_item_AddOption( p_input, ppsz_options[i], VLC_INPUT_OPTION_TRUSTED );
|
||||
}
|
||||
input_item_AddSubItem( p_current_input, p_input );
|
||||
vlc_gc_decref( p_input );
|
||||
|
@ -225,7 +225,7 @@ static int Demux( demux_t *p_demux )
|
||||
|
||||
input_item_AddSubItem( p_current_input, p_input );
|
||||
for( int i = 0; i < i_options; i++ )
|
||||
input_item_AddOpt( p_input, ppsz_options[i], 0 );
|
||||
input_item_AddOption( p_input, ppsz_options[i], 0 );
|
||||
vlc_gc_decref( p_input );
|
||||
free( psz_mrl );
|
||||
}
|
||||
|
@ -393,7 +393,7 @@ static int Demux ( demux_t *p_demux )
|
||||
p_sys->i_packet_size += 1000;
|
||||
if( asprintf( &psz_option, "mtu=%i", p_sys->i_packet_size ) != -1 )
|
||||
{
|
||||
input_item_AddOption( p_child, psz_option );
|
||||
input_item_AddOption( p_child, psz_option, VLC_INPUT_OPTION_TRUSTED );
|
||||
free( psz_option );
|
||||
}
|
||||
}
|
||||
@ -402,7 +402,7 @@ static int Demux ( demux_t *p_demux )
|
||||
char *psz_option;
|
||||
if( asprintf( &psz_option, "rtsp-caching=5000" ) != -1 )
|
||||
{
|
||||
input_item_AddOption( p_child, psz_option );
|
||||
input_item_AddOption( p_child, psz_option, VLC_INPUT_OPTION_TRUSTED );
|
||||
free( psz_option );
|
||||
}
|
||||
}
|
||||
@ -411,7 +411,7 @@ static int Demux ( demux_t *p_demux )
|
||||
char *psz_option;
|
||||
if( asprintf( &psz_option, "rtsp-kasenna" ) != -1 )
|
||||
{
|
||||
input_item_AddOption( p_child, psz_option );
|
||||
input_item_AddOption( p_child, psz_option, VLC_INPUT_OPTION_TRUSTED );
|
||||
free( psz_option );
|
||||
}
|
||||
}
|
||||
|
@ -671,7 +671,7 @@ static bool set_option SIMPLE_INTERFACE
|
||||
/* re-convert xml special characters inside psz_value */
|
||||
resolve_xml_special_chars( psz_value );
|
||||
|
||||
input_item_AddOpt( p_input, psz_value, 0 );
|
||||
input_item_AddOption( p_input, psz_value, 0 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1073,7 +1073,8 @@
|
||||
{
|
||||
for( i = 0; i < (int)[o_options count]; i++ )
|
||||
{
|
||||
input_item_AddOption( p_input, strdup( [[o_options objectAtIndex:i] UTF8String] ) );
|
||||
input_item_AddOption( p_input, strdup( [[o_options objectAtIndex:i] UTF8String] ),
|
||||
VLC_INPUT_OPTION_TRUSTED );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1278,14 +1278,16 @@ static VLCWizard *_o_sharedInstance = nil;
|
||||
objectAtIndex:x] UTF8String],
|
||||
[tempString UTF8String] );
|
||||
input_item_AddOption( p_input, [[[o_userSelections
|
||||
objectForKey:@"opts"] objectAtIndex: x] UTF8String]);
|
||||
objectForKey:@"opts"] objectAtIndex: x] UTF8String],
|
||||
VLC_INPUT_OPTION_TRUSTED );
|
||||
|
||||
if(! [[o_userSelections objectForKey:@"partExtractFrom"]
|
||||
isEqualToString:@""] )
|
||||
{
|
||||
input_item_AddOption( p_input, [[NSString
|
||||
stringWithFormat: @"start-time=%@", [o_userSelections
|
||||
objectForKey: @"partExtractFrom"]] UTF8String] );
|
||||
objectForKey: @"partExtractFrom"]] UTF8String],
|
||||
VLC_INPUT_OPTION_TRUSTED );
|
||||
}
|
||||
|
||||
if(! [[o_userSelections objectForKey:@"partExtractTo"]
|
||||
@ -1293,12 +1295,14 @@ static VLCWizard *_o_sharedInstance = nil;
|
||||
{
|
||||
input_item_AddOption( p_input, [[NSString
|
||||
stringWithFormat: @"stop-time=%@", [o_userSelections
|
||||
objectForKey: @"partExtractTo"]] UTF8String] );
|
||||
objectForKey: @"partExtractTo"]] UTF8String],
|
||||
VLC_INPUT_OPTION_TRUSTED );
|
||||
}
|
||||
|
||||
input_item_AddOption( p_input, [[NSString stringWithFormat:
|
||||
@"ttl=%@", [o_userSelections objectForKey:@"ttl"]]
|
||||
UTF8String] );
|
||||
UTF8String],
|
||||
VLC_INPUT_OPTION_TRUSTED );
|
||||
|
||||
/* FIXME: playlist_AddInput() can fail */
|
||||
playlist_AddInput( p_playlist, p_input, PLAYLIST_STOP,
|
||||
|
@ -331,7 +331,7 @@ void OpenDialog::finish( bool b_enqueue = false )
|
||||
while( i + 1 < tempMRL.size() && tempMRL[i + 1].startsWith( ":" ) )
|
||||
{
|
||||
i++;
|
||||
input_item_AddOption( p_input, qtu( tempMRL[i] ) );
|
||||
input_item_AddOption( p_input, qtu( tempMRL[i] ), VLC_INPUT_OPTION_TRUSTED );
|
||||
}
|
||||
|
||||
/* Switch between enqueuing and starting the item */
|
||||
|
@ -1168,7 +1168,7 @@ void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
|
||||
((const char *)mrl[i + 1].mb_str(wxConvUTF8))[0] == ':' )
|
||||
{
|
||||
psz_utf8 = wxFromLocale( mrl[i + 1] );
|
||||
input_item_AddOption( p_input, psz_utf8 );
|
||||
input_item_AddOption( p_input, psz_utf8, VLC_INPUT_OPTION_TRUSTED );
|
||||
wxLocaleFree( psz_utf8 );
|
||||
i++;
|
||||
}
|
||||
@ -1179,7 +1179,7 @@ void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
|
||||
for( int j = 0; j < (int)subsfile_mrl.GetCount(); j++ )
|
||||
{
|
||||
psz_utf8 = wxFromLocale( subsfile_mrl[j] );
|
||||
input_item_AddOption( p_input, psz_utf8 );
|
||||
input_item_AddOption( p_input, psz_utf8, VLC_INPUT_OPTION_TRUSTED );
|
||||
wxLocaleFree( psz_utf8 );
|
||||
}
|
||||
}
|
||||
@ -1190,7 +1190,7 @@ void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
|
||||
for( int j = 0; j < (int)sout_mrl.GetCount(); j++ )
|
||||
{
|
||||
psz_utf8 = wxFromLocale( sout_mrl[j] );
|
||||
input_item_AddOption( p_input, psz_utf8 );
|
||||
input_item_AddOption( p_input, psz_utf8, VLC_INPUT_OPTION_TRUSTED );
|
||||
wxLocaleFree( psz_utf8 );
|
||||
}
|
||||
}
|
||||
|
@ -1611,23 +1611,23 @@ void WizardDialog::Run()
|
||||
{
|
||||
input_item_t *p_input = input_item_New( p_playlist, mrl,
|
||||
ITEM_NAME );
|
||||
input_item_AddOption( p_input, psz_opt );
|
||||
input_item_AddOption( p_input, psz_opt, VLC_INPUT_OPTION_TRUSTED );
|
||||
if( i_from != 0)
|
||||
{
|
||||
char psz_from[20];
|
||||
snprintf( psz_from, 20, "start-time=%i", i_from);
|
||||
input_item_AddOption( p_input, psz_from );
|
||||
input_item_AddOption( p_input, psz_from, VLC_INPUT_OPTION_TRUSTED );
|
||||
}
|
||||
if( i_to != 0)
|
||||
{
|
||||
char psz_to[20];
|
||||
snprintf( psz_to, 20, "stop-time=%i", i_to);
|
||||
input_item_AddOption( p_input, psz_to );
|
||||
input_item_AddOption( p_input, psz_to, VLC_INPUT_OPTION_TRUSTED );
|
||||
}
|
||||
|
||||
char psz_ttl[20];
|
||||
snprintf( psz_ttl, 20, "ttl=%i",i_ttl );
|
||||
input_item_AddOption( p_input, psz_ttl );
|
||||
input_item_AddOption( p_input, psz_ttl, VLC_INPUT_OPTION_TRUSTED );
|
||||
|
||||
/* FIXME: playlist_AddInput() can fail */
|
||||
playlist_AddInput( p_playlist, p_input,
|
||||
|
@ -247,7 +247,7 @@ static void ParseUrls( services_discovery_t *p_sd, char *psz_urls )
|
||||
strdup( psz_urls ) );
|
||||
p_input = input_item_NewExt( p_sd, psz_urls,
|
||||
psz_urls, 0, NULL, -1 );
|
||||
input_item_AddOption( p_input, "demux=podcast" );
|
||||
input_item_AddOption( p_input, "demux=podcast", VLC_INPUT_OPTION_TRUSTED );
|
||||
services_discovery_AddItem( p_sd, p_input, NULL /* no cat */ );
|
||||
vlc_gc_decref( p_input );
|
||||
INSERT_ELEM( p_sys->pp_input, p_sys->i_input, p_sys->i_input,
|
||||
|
@ -664,7 +664,7 @@ static int Demux( demux_t *p_demux )
|
||||
char *rtcp;
|
||||
if( asprintf( &rtcp, ":rtcp-port=%u", p_sdp->rtcp_port ) != -1 )
|
||||
{
|
||||
input_item_AddOption( p_parent_input, rtcp );
|
||||
input_item_AddOption( p_parent_input, rtcp, VLC_INPUT_OPTION_TRUSTED );
|
||||
free( rtcp );
|
||||
}
|
||||
}
|
||||
@ -880,7 +880,7 @@ sap_announce_t *CreateAnnounce( services_discovery_t *p_sd, uint16_t i_hash,
|
||||
char *rtcp;
|
||||
if( asprintf( &rtcp, ":rtcp-port=%u", p_sdp->rtcp_port ) != -1 )
|
||||
{
|
||||
input_item_AddOption( p_input, rtcp );
|
||||
input_item_AddOption( p_input, rtcp, VLC_INPUT_OPTION_TRUSTED );
|
||||
free( rtcp );
|
||||
}
|
||||
}
|
||||
|
@ -192,8 +192,8 @@ static input_item_t * CreateInputItemFromShoutItem( services_discovery_t *p_sd,
|
||||
|
||||
/* Copy options */
|
||||
for( i = 0; p_item->ppsz_options[i] != NULL; i++ )
|
||||
input_item_AddOption( p_input, p_item->ppsz_options[i] );
|
||||
input_item_AddOption( p_input, "no-playlist-autostart" );
|
||||
input_item_AddOption( p_input, p_item->ppsz_options[i], VLC_INPUT_OPTION_TRUSTED );
|
||||
input_item_AddOption( p_input, "no-playlist-autostart", VLC_INPUT_OPTION_TRUSTED );
|
||||
|
||||
return p_input;
|
||||
}
|
||||
|
@ -346,8 +346,8 @@ void libvlc_media_add_option(
|
||||
libvlc_exception_t *p_e )
|
||||
{
|
||||
VLC_UNUSED(p_e);
|
||||
input_item_AddOpt( p_md->p_input_item, ppsz_option,
|
||||
VLC_INPUT_OPTION_UNIQUE|VLC_INPUT_OPTION_TRUSTED );
|
||||
input_item_AddOption( p_md->p_input_item, ppsz_option,
|
||||
VLC_INPUT_OPTION_UNIQUE|VLC_INPUT_OPTION_TRUSTED );
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
|
@ -318,8 +318,8 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
|
||||
if( asprintf( &str, "%s=%s", psz_option, psz_value ) == -1 )
|
||||
return VLC_ENOMEM;
|
||||
|
||||
i = input_item_AddOpt( p_input->p->p_item, str,
|
||||
VLC_INPUT_OPTION_UNIQUE );
|
||||
i = input_item_AddOption( p_input->p->p_item, str,
|
||||
VLC_INPUT_OPTION_UNIQUE );
|
||||
free( str );
|
||||
return i;
|
||||
}
|
||||
@ -489,7 +489,7 @@ static void UpdateBookmarksOption( input_thread_t *p_input )
|
||||
vlc_mutex_unlock( &p_input->p->p_item->lock );
|
||||
|
||||
if( psz_value )
|
||||
input_item_AddOpt( p_input->p->p_item, psz_value, VLC_INPUT_OPTION_UNIQUE );
|
||||
input_item_AddOption( p_input->p->p_item, psz_value, VLC_INPUT_OPTION_UNIQUE );
|
||||
|
||||
free( psz_value );
|
||||
|
||||
|
@ -223,9 +223,9 @@ void input_item_CopyOptions( input_item_t *p_parent,
|
||||
if( !strcmp( p_parent->ppsz_options[i], "meta-file" ) )
|
||||
continue;
|
||||
|
||||
input_item_AddOpt( p_child,
|
||||
p_parent->ppsz_options[i],
|
||||
p_parent->optflagv[i] );
|
||||
input_item_AddOption( p_child,
|
||||
p_parent->ppsz_options[i],
|
||||
p_parent->optflagv[i] );
|
||||
}
|
||||
|
||||
vlc_mutex_unlock( &p_parent->lock );
|
||||
@ -251,11 +251,6 @@ void input_item_AddSubItem( input_item_t *p_parent, input_item_t *p_child )
|
||||
vlc_event_send( &p_parent->event_manager, &event );
|
||||
}
|
||||
|
||||
int input_item_AddOption( input_item_t *p_item, const char *psz_option )
|
||||
{
|
||||
return input_item_AddOpt( p_item, psz_option, VLC_INPUT_OPTION_TRUSTED );
|
||||
}
|
||||
|
||||
bool input_item_HasErrorWhenReading( input_item_t *p_item )
|
||||
{
|
||||
vlc_mutex_lock( &p_item->lock );
|
||||
@ -451,8 +446,8 @@ static void input_item_Destroy ( gc_object_t *p_gc )
|
||||
free( p_item );
|
||||
}
|
||||
|
||||
int input_item_AddOpt( input_item_t *p_input, const char *psz_option,
|
||||
unsigned flags )
|
||||
int input_item_AddOption( input_item_t *p_input, const char *psz_option,
|
||||
unsigned flags )
|
||||
{
|
||||
int err = VLC_SUCCESS;
|
||||
|
||||
@ -677,7 +672,7 @@ input_item_t *input_item_NewWithType( vlc_object_t *p_obj, const char *psz_uri,
|
||||
p_input->i_duration = i_duration;
|
||||
|
||||
for( int i = 0; i < i_options; i++ )
|
||||
input_item_AddOption( p_input, ppsz_options[i] );
|
||||
input_item_AddOption( p_input, ppsz_options[i], VLC_INPUT_OPTION_TRUSTED );
|
||||
return p_input;
|
||||
}
|
||||
|
||||
|
@ -514,14 +514,14 @@ static int vlm_OnMediaUpdate( vlm_t *p_vlm, vlm_media_sys_t *p_media )
|
||||
|
||||
if( psz_output && asprintf( &psz_dup, "sout=%s", psz_output ) != -1 )
|
||||
{
|
||||
input_item_AddOption( p_media->vod.p_item, psz_dup );
|
||||
input_item_AddOption( p_media->vod.p_item, psz_dup, VLC_INPUT_OPTION_TRUSTED );
|
||||
free( psz_dup );
|
||||
}
|
||||
free( psz_output );
|
||||
|
||||
for( i = 0; i < p_cfg->i_option; i++ )
|
||||
input_item_AddOption( p_media->vod.p_item,
|
||||
p_cfg->ppsz_option[i] );
|
||||
p_cfg->ppsz_option[i], VLC_INPUT_OPTION_TRUSTED );
|
||||
|
||||
if( asprintf( &psz_header, _("Media: %s"), p_cfg->psz_name ) == -1 )
|
||||
psz_header = NULL;
|
||||
@ -818,7 +818,7 @@ static int vlm_ControlMediaInstanceStart( vlm_t *p_vlm, int64_t id, const char *
|
||||
(p_cfg->psz_output && psz_vod_output) ? ":" : psz_vod_output ? "#" : "",
|
||||
psz_vod_output ? psz_vod_output : "" ) != -1 )
|
||||
{
|
||||
input_item_AddOption( p_instance->p_item, psz_buffer );
|
||||
input_item_AddOption( p_instance->p_item, psz_buffer, VLC_INPUT_OPTION_TRUSTED );
|
||||
free( psz_buffer );
|
||||
}
|
||||
}
|
||||
@ -830,7 +830,7 @@ static int vlm_ControlMediaInstanceStart( vlm_t *p_vlm, int64_t id, const char *
|
||||
else if( !strcmp( p_cfg->ppsz_option[i], "nosout-keep" ) || !strcmp( p_cfg->ppsz_option[i], "no-sout-keep" ) )
|
||||
p_instance->b_sout_keep = false;
|
||||
else
|
||||
input_item_AddOption( p_instance->p_item, p_cfg->ppsz_option[i] );
|
||||
input_item_AddOption( p_instance->p_item, p_cfg->ppsz_option[i], VLC_INPUT_OPTION_TRUSTED );
|
||||
}
|
||||
TAB_APPEND( p_media->i_instance, p_media->instance, p_instance );
|
||||
}
|
||||
|
@ -162,7 +162,6 @@ input_DecoderDelete
|
||||
input_DecoderNew
|
||||
input_GetItem
|
||||
input_item_AddInfo
|
||||
input_item_AddOpt
|
||||
input_item_AddOption
|
||||
input_item_AddSubItem
|
||||
input_item_CopyOptions
|
||||
|
Loading…
Reference in New Issue
Block a user