[vlc-commits] demux/playlist: ensure that a playlist is a file

Thomas Guillem git at videolan.org
Thu May 7 18:25:07 CEST 2015


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu May  7 16:55:01 2015 +0200| [dc39e0ea3066898e67c67d3b4004f0fe869ac3d4] | committer: Thomas Guillem

demux/playlist: ensure that a playlist is a file

A lot of playlist probe only check the file extension that returns true for a
directory too.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=dc39e0ea3066898e67c67d3b4004f0fe869ac3d4
---

 modules/demux/playlist/asx.c       |    1 +
 modules/demux/playlist/b4s.c       |    1 +
 modules/demux/playlist/dvb.c       |    5 +++--
 modules/demux/playlist/gvp.c       |    1 +
 modules/demux/playlist/ifo.c       |    1 +
 modules/demux/playlist/m3u.c       |    1 +
 modules/demux/playlist/playlist.h  |   10 ++++++++++
 modules/demux/playlist/pls.c       |    1 +
 modules/demux/playlist/podcast.c   |    1 +
 modules/demux/playlist/qtl.c       |    1 +
 modules/demux/playlist/ram.c       |    1 +
 modules/demux/playlist/sgimb.c     |    1 +
 modules/demux/playlist/shoutcast.c |    1 +
 modules/demux/playlist/wpl.c       |    2 ++
 14 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/modules/demux/playlist/asx.c b/modules/demux/playlist/asx.c
index 6f6e666..cd93692 100644
--- a/modules/demux/playlist/asx.c
+++ b/modules/demux/playlist/asx.c
@@ -145,6 +145,7 @@ int Import_ASX( vlc_object_t *p_this )
 {
     demux_t *p_demux = (demux_t *)p_this;
 
+    CHECK_FILE();
     if( demux_IsPathExtension( p_demux, ".asx" ) ||
         demux_IsPathExtension( p_demux, ".wax" ) ||
         demux_IsPathExtension( p_demux, ".wvx" ) ||
diff --git a/modules/demux/playlist/b4s.c b/modules/demux/playlist/b4s.c
index d9c0465..cea6d85 100644
--- a/modules/demux/playlist/b4s.c
+++ b/modules/demux/playlist/b4s.c
@@ -49,6 +49,7 @@ int Import_B4S( vlc_object_t *p_this )
 {
     demux_t *demux = (demux_t *)p_this;
 
+    CHECK_FILE();
     if( !demux_IsPathExtension( demux, ".b4s" )
      && !demux_IsForced( demux, "b4s-open" ) )
         return VLC_EGENERIC;
diff --git a/modules/demux/playlist/dvb.c b/modules/demux/playlist/dvb.c
index 0b5e796..94289a4 100644
--- a/modules/demux/playlist/dvb.c
+++ b/modules/demux/playlist/dvb.c
@@ -42,10 +42,11 @@ static int Demux(demux_t *);
 static input_item_t *ParseLine(char *line);
 
 /** Detect dvb-utils zap channels.conf format */
-int Import_DVB(vlc_object_t *obj)
+int Import_DVB(vlc_object_t *p_this)
 {
-    demux_t *demux = (demux_t *)obj;
+    demux_t *demux = (demux_t *)p_this;
 
+    CHECK_FILE();
     if (!demux_IsPathExtension(demux, ".conf" ) && !demux->b_force )
         return VLC_EGENERIC;
 
diff --git a/modules/demux/playlist/gvp.c b/modules/demux/playlist/gvp.c
index e28e09b..2eca158 100644
--- a/modules/demux/playlist/gvp.c
+++ b/modules/demux/playlist/gvp.c
@@ -73,6 +73,7 @@ int Import_GVP( vlc_object_t *p_this )
     int i_peek, i, b_found = false;
     const uint8_t *p_peek;
 
+    CHECK_FILE();
     i_peek = stream_Peek( p_demux->s, &p_peek, MAX_LINE );
 
     for( i = 0; i < i_peek - (int)sizeof("gvp_version:"); i++ )
diff --git a/modules/demux/playlist/ifo.c b/modules/demux/playlist/ifo.c
index e031f8b..7d3bf4f 100644
--- a/modules/demux/playlist/ifo.c
+++ b/modules/demux/playlist/ifo.c
@@ -47,6 +47,7 @@ int Import_IFO( vlc_object_t *p_this )
 {
     demux_t *p_demux = (demux_t *)p_this;
 
+    CHECK_FILE();
     if( !p_demux->psz_file )
         return VLC_EGENERIC;
 
diff --git a/modules/demux/playlist/m3u.c b/modules/demux/playlist/m3u.c
index 02a9598..a0572ff 100644
--- a/modules/demux/playlist/m3u.c
+++ b/modules/demux/playlist/m3u.c
@@ -69,6 +69,7 @@ int Import_M3U( vlc_object_t *p_this )
     char *(*pf_dup) (const char *) = GuessEncoding;
     int offset = 0;
 
+    CHECK_FILE();
     if( stream_Peek( p_demux->s, &p_peek, 3 ) == 3
      && !memcmp( p_peek, "\xef\xbb\xbf", 3) )
     {
diff --git a/modules/demux/playlist/playlist.h b/modules/demux/playlist/playlist.h
index 64245f2..ea6ef4b 100644
--- a/modules/demux/playlist/playlist.h
+++ b/modules/demux/playlist/playlist.h
@@ -82,24 +82,34 @@ extern input_item_t * GetCurrentItem(demux_t *p_demux);
 
 bool CheckContentType( stream_t * p_stream, const char * psz_ctype );
 
+#define CHECK_FILE() do { \
+    bool b_is_dir = false; \
+    stream_Control( ((demux_t *)p_this)->s, STREAM_IS_DIRECTORY, &b_is_dir ); \
+    if( b_is_dir ) \
+        return VLC_EGENERIC; \
+} while(0)
+
 #define STANDARD_DEMUX_INIT_MSG( msg ) do { \
     DEMUX_INIT_COMMON();                    \
     msg_Dbg( p_demux, "%s", msg ); } while(0)
 
 #define DEMUX_BY_EXTENSION_MSG( ext, msg ) \
     demux_t *p_demux = (demux_t *)p_this; \
+    CHECK_FILE(); \
     if( !demux_IsPathExtension( p_demux, ext ) ) \
         return VLC_EGENERIC; \
     STANDARD_DEMUX_INIT_MSG( msg );
 
 #define DEMUX_BY_EXTENSION_OR_FORCED_MSG( ext, module, msg ) \
     demux_t *p_demux = (demux_t *)p_this; \
+    CHECK_FILE(); \
     if( !demux_IsPathExtension( p_demux, ext ) && !demux_IsForced( p_demux, module ) ) \
         return VLC_EGENERIC; \
     STANDARD_DEMUX_INIT_MSG( msg );
 
 #define DEMUX_BY_EXTENSION_OR_MIMETYPE( ext, mime, msg ) \
     demux_t *p_demux = (demux_t *)p_this; \
+    CHECK_FILE(); \
     char* demux_mimetype = stream_ContentType( p_demux->s ); \
     if(!( demux_IsPathExtension( p_demux, ext ) || (demux_mimetype && !strcasecmp( mime, demux_mimetype )) )) { \
         free( demux_mimetype ); \
diff --git a/modules/demux/playlist/pls.c b/modules/demux/playlist/pls.c
index 6c30831..7646aae 100644
--- a/modules/demux/playlist/pls.c
+++ b/modules/demux/playlist/pls.c
@@ -51,6 +51,7 @@ int Import_PLS( vlc_object_t *p_this )
 {
     demux_t *p_demux = (demux_t *)p_this;
     const uint8_t *p_peek;
+    CHECK_FILE();
     CHECK_PEEK( p_peek, 10 );
 
     if( POKE( p_peek, "[playlist]", 10 ) || POKE( p_peek, "[Reference]", 10 ) ||
diff --git a/modules/demux/playlist/podcast.c b/modules/demux/playlist/podcast.c
index 3c52803..079d99b 100644
--- a/modules/demux/playlist/podcast.c
+++ b/modules/demux/playlist/podcast.c
@@ -48,6 +48,7 @@ int Import_podcast( vlc_object_t *p_this )
 {
     demux_t *p_demux = (demux_t *)p_this;
 
+    CHECK_FILE();
     if( !demux_IsForced( p_demux, "podcast" ) )
         return VLC_EGENERIC;
 
diff --git a/modules/demux/playlist/qtl.c b/modules/demux/playlist/qtl.c
index 958b29e..968e5f8 100644
--- a/modules/demux/playlist/qtl.c
+++ b/modules/demux/playlist/qtl.c
@@ -82,6 +82,7 @@ int Import_QTL( vlc_object_t *p_this )
 {
     demux_t *p_demux = (demux_t *)p_this;
 
+    CHECK_FILE();
     if( !demux_IsPathExtension( p_demux, ".qtl" ) )
         return VLC_EGENERIC;
 
diff --git a/modules/demux/playlist/ram.c b/modules/demux/playlist/ram.c
index 697199b..c217a3d 100644
--- a/modules/demux/playlist/ram.c
+++ b/modules/demux/playlist/ram.c
@@ -79,6 +79,7 @@ int Import_RAM( vlc_object_t *p_this )
     demux_t *p_demux = (demux_t *)p_this;
     const uint8_t *p_peek;
 
+    CHECK_FILE();
     if(! demux_IsPathExtension( p_demux, ".ram" ) ||
          demux_IsPathExtension( p_demux, ".rm" ) )
         return VLC_EGENERIC;
diff --git a/modules/demux/playlist/sgimb.c b/modules/demux/playlist/sgimb.c
index fd2e064..7aa4d0c 100644
--- a/modules/demux/playlist/sgimb.c
+++ b/modules/demux/playlist/sgimb.c
@@ -140,6 +140,7 @@ int Import_SGIMB( vlc_object_t * p_this )
     const uint8_t *p_peek;
     int i_size;
 
+    CHECK_FILE();
     /* Lets check the content to see if this is a sgi mediabase file */
     i_size = stream_Peek( p_demux->s, &p_peek, MAX_LINE );
     i_size -= sizeof("sgiNameServerHost=") - 1;
diff --git a/modules/demux/playlist/shoutcast.c b/modules/demux/playlist/shoutcast.c
index 499ba3d..4d10307 100644
--- a/modules/demux/playlist/shoutcast.c
+++ b/modules/demux/playlist/shoutcast.c
@@ -59,6 +59,7 @@ int Import_Shoutcast( vlc_object_t *p_this )
 {
     demux_t *p_demux = (demux_t *)p_this;
 
+    CHECK_FILE();
     if( !demux_IsForced( p_demux, "shout-winamp" ) )
         return VLC_EGENERIC;
 
diff --git a/modules/demux/playlist/wpl.c b/modules/demux/playlist/wpl.c
index ec28420..707edd9 100644
--- a/modules/demux/playlist/wpl.c
+++ b/modules/demux/playlist/wpl.c
@@ -172,6 +172,8 @@ void Close_WPL( vlc_object_t* p_this )
 int Import_WPL( vlc_object_t* p_this )
 {
     demux_t* p_demux = (demux_t*)p_this;
+
+    CHECK_FILE();
     if( !demux_IsPathExtension( p_demux, ".wpl" ) &&
         !demux_IsPathExtension( p_demux, ".zpl" ) )
         return VLC_EGENERIC;



More information about the vlc-commits mailing list