[vlc-commits] access_demux: check that ES output is non-NULL

Rémi Denis-Courmont git at videolan.org
Thu Mar 29 17:23:10 CEST 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Mar 24 13:01:54 2018 +0200| [eb171844342b4d948eb29c7e3b2c866d45200381] | committer: Rémi Denis-Courmont

access_demux: check that ES output is non-NULL

A combined access-demux cannot be instantiated without an ES output.
This checks that the ES output is present, avoiding crashes for
instance with vlc_stream_NewURL().

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

 modules/access/alsa.c                | 4 ++++
 modules/access/avcapture.m           | 3 +++
 modules/access/bluray.c              | 2 +-
 modules/access/cdda.c                | 3 +++
 modules/access/dc1394.c              | 3 +++
 modules/access/dcp/dcp.cpp           | 2 +-
 modules/access/decklink.cpp          | 3 +++
 modules/access/dshow/dshow.cpp       | 3 +++
 modules/access/dvdnav.c              | 3 +++
 modules/access/dvdread.c             | 3 +++
 modules/access/imem.c                | 3 +++
 modules/access/jack.c                | 3 +++
 modules/access/linsys/linsys_hdsdi.c | 3 +++
 modules/access/linsys/linsys_sdi.c   | 3 +++
 modules/access/live555.cpp           | 3 +++
 modules/access/oss.c                 | 3 +++
 modules/access/pulse.c               | 3 +++
 modules/access/qtsound.m             | 3 +++
 modules/access/rdp.c                 | 3 +++
 modules/access/rtp/rtp.c             | 3 +++
 modules/access/screen/screen.c       | 3 +++
 modules/access/screen/wayland.c      | 3 +++
 modules/access/screen/xcb.c          | 4 +++-
 modules/access/shm.c                 | 3 +++
 modules/access/timecode.c            | 4 +++-
 modules/access/v4l2/demux.c          | 2 ++
 modules/access/v4l2/radio.c          | 2 ++
 modules/access/vnc.c                 | 3 +++
 modules/access/wasapi.c              | 3 +++
 29 files changed, 82 insertions(+), 4 deletions(-)

diff --git a/modules/access/alsa.c b/modules/access/alsa.c
index 69777788b6..5cc0768de8 100644
--- a/modules/access/alsa.c
+++ b/modules/access/alsa.c
@@ -341,6 +341,10 @@ static uint16_t channel_maps[] = {
 static int Open (vlc_object_t *obj)
 {
     demux_t *demux = (demux_t *)obj;
+
+    if (demux->out == NULL)
+        return VLC_EGENERIC;
+
     demux_sys_t *sys = vlc_obj_malloc(obj, sizeof (*sys));
     if (unlikely(sys == NULL))
         return VLC_ENOMEM;
diff --git a/modules/access/avcapture.m b/modules/access/avcapture.m
index 30b9c199ef..278e7f8e94 100644
--- a/modules/access/avcapture.m
+++ b/modules/access/avcapture.m
@@ -257,6 +257,9 @@ static int Open(vlc_object_t *p_this)
 
     char                    *psz_uid = NULL;
 
+    if (p_demux->out == NULL)
+        return VLC_EGENERIC;
+
     @autoreleasepool {
         if (p_demux->psz_location && *p_demux->psz_location)
             psz_uid = strdup(p_demux->psz_location);
diff --git a/modules/access/bluray.c b/modules/access/bluray.c
index 126acb7d44..cf4676a302 100644
--- a/modules/access/bluray.c
+++ b/modules/access/bluray.c
@@ -632,7 +632,7 @@ static int blurayOpen(vlc_object_t *object)
     const char *error_msg = NULL;
 #define BLURAY_ERROR(s) do { error_msg = s; goto error; } while(0)
 
-    if (unlikely(!p_demux->p_input))
+    if (p_demux->out == NULL || unlikely(p_demux->p_input == NULL))
         return VLC_EGENERIC;
 
     forced = !strncasecmp(p_demux->psz_url, "bluray:", 7);
diff --git a/modules/access/cdda.c b/modules/access/cdda.c
index 6a6815df24..384dfb03a4 100644
--- a/modules/access/cdda.c
+++ b/modules/access/cdda.c
@@ -217,6 +217,9 @@ static int DemuxOpen(vlc_object_t *obj)
     demux_t *demux = (demux_t *)obj;
     unsigned track;
 
+    if (demux->out == NULL)
+        return VLC_EGENERIC;
+
     vcddev_t *dev = DiscOpen(obj, demux->psz_location, demux->psz_filepath,
                              &track);
     if (dev == NULL)
diff --git a/modules/access/dc1394.c b/modules/access/dc1394.c
index cf523fbf3c..631abf6f9b 100644
--- a/modules/access/dc1394.c
+++ b/modules/access/dc1394.c
@@ -166,6 +166,9 @@ static int Open( vlc_object_t *p_this )
     es_format_t   fmt;
     dc1394error_t res;
 
+    if (p_demux->out == NULL)
+        return VLC_EGENERIC;
+
     /* Set up p_demux */
     p_demux->pf_demux = Demux;
     p_demux->pf_control = Control;
diff --git a/modules/access/dcp/dcp.cpp b/modules/access/dcp/dcp.cpp
index b1b846522c..e53813beb3 100644
--- a/modules/access/dcp/dcp.cpp
+++ b/modules/access/dcp/dcp.cpp
@@ -306,7 +306,7 @@ static int Open( vlc_object_t *obj )
     es_format_t video_format, audio_format;
     int retval;
 
-    if( !p_demux->psz_filepath )
+    if( p_demux->out == NULL || p_demux->psz_filepath == NULL )
         return VLC_EGENERIC;
 
     p_sys = new ( nothrow ) demux_sys_t();
diff --git a/modules/access/decklink.cpp b/modules/access/decklink.cpp
index 5d54b15d87..761396c75a 100644
--- a/modules/access/decklink.cpp
+++ b/modules/access/decklink.cpp
@@ -487,6 +487,9 @@ static int Open(vlc_object_t *p_this)
     int         rate;
     BMDVideoInputFlags flags = bmdVideoInputFlagDefault;
 
+    if (demux->out == NULL)
+        return VLC_EGENERIC;
+
     /* Set up demux */
     demux->pf_demux = NULL;
     demux->pf_control = Control;
diff --git a/modules/access/dshow/dshow.cpp b/modules/access/dshow/dshow.cpp
index ef615e6628..100d9b9a65 100644
--- a/modules/access/dshow/dshow.cpp
+++ b/modules/access/dshow/dshow.cpp
@@ -670,6 +670,9 @@ static int DemuxOpen( vlc_object_t *p_this )
     demux_t      *p_demux = (demux_t *)p_this;
     access_sys_t *p_sys;
 
+    if (p_demux->out == NULL)
+        return VLC_EGENERIC;
+
     p_sys = (access_sys_t*)calloc( 1, sizeof( access_sys_t ) );
     if( !p_sys )
         return VLC_ENOMEM;
diff --git a/modules/access/dvdnav.c b/modules/access/dvdnav.c
index c21fe826b0..b6fe4304c3 100644
--- a/modules/access/dvdnav.c
+++ b/modules/access/dvdnav.c
@@ -349,6 +349,9 @@ static int AccessDemuxOpen ( vlc_object_t *p_this )
     int i_ret = VLC_EGENERIC;
     bool forced = false;
 
+    if (p_demux->out == NULL)
+        return VLC_EGENERIC;
+
     if( !strncasecmp(p_demux->psz_url, "dvd", 3) )
         forced = true;
 
diff --git a/modules/access/dvdread.c b/modules/access/dvdread.c
index bd708d99af..8bf626298a 100644
--- a/modules/access/dvdread.c
+++ b/modules/access/dvdread.c
@@ -169,6 +169,9 @@ static int Open( vlc_object_t *p_this )
     char         *psz_file;
     ifo_handle_t *p_vmg_file;
 
+    if (p_demux->out == NULL)
+        return VLC_EGENERIC;
+
     if( !p_demux->psz_filepath || !*p_demux->psz_filepath )
         psz_file = var_InheritString( p_this, "dvd" );
     else
diff --git a/modules/access/imem.c b/modules/access/imem.c
index d98c5f3d08..668b0e5000 100644
--- a/modules/access/imem.c
+++ b/modules/access/imem.c
@@ -416,6 +416,9 @@ static int OpenDemux(vlc_object_t *object)
     demux_t    *demux = (demux_t *)object;
     imem_sys_t *sys;
 
+    if (demux->out == NULL)
+        return VLC_EGENERIC;
+
     if (OpenCommon(object, &sys, demux->psz_location))
         return VLC_EGENERIC;
 
diff --git a/modules/access/jack.c b/modules/access/jack.c
index 3ef6028719..4a066e32ec 100644
--- a/modules/access/jack.c
+++ b/modules/access/jack.c
@@ -127,6 +127,9 @@ static int Open( vlc_object_t *p_this )
     es_format_t fmt;
     int i_out_ports = 0;
 
+    if (p_demux->out == NULL)
+        return VLC_EGENERIC;
+
     p_demux->pf_demux = Demux;
     p_demux->pf_control = Control;
 
diff --git a/modules/access/linsys/linsys_hdsdi.c b/modules/access/linsys/linsys_hdsdi.c
index a9573ba714..9924290a99 100644
--- a/modules/access/linsys/linsys_hdsdi.c
+++ b/modules/access/linsys/linsys_hdsdi.c
@@ -175,6 +175,9 @@ static int Open( vlc_object_t *p_this )
     demux_sys_t *p_sys;
     char        *psz_parser;
 
+    if (p_demux->out == NULL)
+        return VLC_EGENERIC;
+
     /* Fill p_demux field */
     p_demux->p_sys = p_sys = calloc( 1, sizeof( demux_sys_t ) );
     if( unlikely(!p_sys) )
diff --git a/modules/access/linsys/linsys_sdi.c b/modules/access/linsys/linsys_sdi.c
index 86616806fd..9c544d1003 100644
--- a/modules/access/linsys/linsys_sdi.c
+++ b/modules/access/linsys/linsys_sdi.c
@@ -212,6 +212,9 @@ static int DemuxOpen( vlc_object_t *p_this )
     demux_sys_t *p_sys;
     char        *psz_parser;
 
+    if (p_demux->out == NULL)
+        return VLC_EGENERIC;
+
     /* Fill p_demux field */
     p_demux->pf_demux = DemuxDemux;
     p_demux->pf_control = DemuxControl;
diff --git a/modules/access/live555.cpp b/modules/access/live555.cpp
index e7b7a83090..b2c32867e8 100644
--- a/modules/access/live555.cpp
+++ b/modules/access/live555.cpp
@@ -300,6 +300,9 @@ static int  Open ( vlc_object_t *p_this )
     int i_return;
     int i_error = VLC_EGENERIC;
 
+    if (p_demux->out == NULL)
+        return VLC_EGENERIC;
+
     /* if the rtsp URL may contain a sat.ip fake DNS, bail-out early and 
      * let the SAT>IP module handle that */
     if( !strncmp(p_demux->psz_location, "sat.ip", 6) )
diff --git a/modules/access/oss.c b/modules/access/oss.c
index 477b1c64cd..367aed1574 100644
--- a/modules/access/oss.c
+++ b/modules/access/oss.c
@@ -152,6 +152,9 @@ static int DemuxOpen( vlc_object_t *p_this )
     demux_t     *p_demux = (demux_t*)p_this;
     demux_sys_t *p_sys;
 
+    if (p_demux->out == NULL)
+        return VLC_EGENERIC;
+
     /* Set up p_demux */
     p_demux->pf_control = DemuxControl;
     p_demux->pf_demux = Demux;
diff --git a/modules/access/pulse.c b/modules/access/pulse.c
index 4ad7477374..4f75e2f660 100644
--- a/modules/access/pulse.c
+++ b/modules/access/pulse.c
@@ -255,6 +255,9 @@ static int Open(vlc_object_t *obj)
 {
     demux_t *demux = (demux_t *)obj;
 
+    if (demux->out == NULL)
+        return VLC_EGENERIC;
+
     demux_sys_t *sys = vlc_obj_malloc(obj, sizeof (*sys));
     if (unlikely(sys == NULL))
         return VLC_ENOMEM;
diff --git a/modules/access/qtsound.m b/modules/access/qtsound.m
index 9c26ebb217..82a1c03269 100644
--- a/modules/access/qtsound.m
+++ b/modules/access/qtsound.m
@@ -244,6 +244,9 @@ static int Open(vlc_object_t *p_this)
     QTCaptureDeviceInput *audioInput;
     NSError *o_returnedAudioError;
 
+    if (p_demux->out == NULL)
+        return VLC_EGENERIC;
+
     @autoreleasepool {
         if(p_demux->psz_location && *p_demux->psz_location)
             psz_uid = p_demux->psz_location;
diff --git a/modules/access/rdp.c b/modules/access/rdp.c
index 7e6be4c1fd..afb29c671f 100644
--- a/modules/access/rdp.c
+++ b/modules/access/rdp.c
@@ -426,6 +426,9 @@ static int Open( vlc_object_t *p_this )
     demux_t      *p_demux = (demux_t*)p_this;
     demux_sys_t  *p_sys;
 
+    if (p_demux->out == NULL)
+        return VLC_EGENERIC;
+
     p_sys = vlc_obj_calloc( p_this, 1, sizeof(demux_sys_t) );
     if( !p_sys ) return VLC_ENOMEM;
 
diff --git a/modules/access/rtp/rtp.c b/modules/access/rtp/rtp.c
index 48a2b4bc19..136600cb02 100644
--- a/modules/access/rtp/rtp.c
+++ b/modules/access/rtp/rtp.c
@@ -162,6 +162,9 @@ static int Open (vlc_object_t *obj)
     demux_t *demux = (demux_t *)obj;
     int tp; /* transport protocol */
 
+    if (demux->out == NULL)
+        return VLC_EGENERIC;
+
     if (!strcasecmp(demux->psz_name, "dccp"))
         tp = IPPROTO_DCCP;
     else
diff --git a/modules/access/screen/screen.c b/modules/access/screen/screen.c
index 59eaaa6eca..a3a267c729 100644
--- a/modules/access/screen/screen.c
+++ b/modules/access/screen/screen.c
@@ -144,6 +144,9 @@ static int Open( vlc_object_t *p_this )
     demux_t     *p_demux = (demux_t*)p_this;
     demux_sys_t *p_sys;
 
+    if (p_demux->out == NULL)
+        return VLC_EGENERIC;
+
     /* Fill p_demux field */
     p_demux->pf_demux = Demux;
     p_demux->pf_control = Control;
diff --git a/modules/access/screen/wayland.c b/modules/access/screen/wayland.c
index 1e6c178144..28b658984e 100644
--- a/modules/access/screen/wayland.c
+++ b/modules/access/screen/wayland.c
@@ -358,6 +358,9 @@ static const struct wl_registry_listener registry_cbs =
 static int Open(vlc_object_t *obj)
 {
     demux_t *demux = (demux_t *)obj;
+    if (demux->out == NULL)
+        return VLC_EGENERIC;
+
     demux_sys_t *sys = malloc(sizeof (*sys));
     if (unlikely(sys == NULL))
         return VLC_ENOMEM;
diff --git a/modules/access/screen/xcb.c b/modules/access/screen/xcb.c
index 4833030c3b..eb2219a1b2 100644
--- a/modules/access/screen/xcb.c
+++ b/modules/access/screen/xcb.c
@@ -142,8 +142,10 @@ static bool CheckSHM (xcb_connection_t *conn)
 static int Open (vlc_object_t *obj)
 {
     demux_t *demux = (demux_t *)obj;
-    demux_sys_t *p_sys = malloc (sizeof (*p_sys));
+    if (demux->out == NULL)
+        return VLC_EGENERIC;
 
+    demux_sys_t *p_sys = malloc (sizeof (*p_sys));
     if (p_sys == NULL)
         return VLC_ENOMEM;
     demux->p_sys = p_sys;
diff --git a/modules/access/shm.c b/modules/access/shm.c
index ecbf0860a3..de6853684d 100644
--- a/modules/access/shm.c
+++ b/modules/access/shm.c
@@ -138,6 +138,9 @@ struct demux_sys_t
 static int Open (vlc_object_t *obj)
 {
     demux_t *demux = (demux_t *)obj;
+    if (demux->out == NULL)
+        return VLC_EGENERIC;
+
     demux_sys_t *sys = vlc_obj_malloc(obj, sizeof (*sys));
     if (unlikely(sys == NULL))
         return VLC_ENOMEM;
diff --git a/modules/access/timecode.c b/modules/access/timecode.c
index 3f962c5dce..c80852c1f1 100644
--- a/modules/access/timecode.c
+++ b/modules/access/timecode.c
@@ -167,8 +167,10 @@ static int Control (demux_t *demux, int query, va_list args)
 static int Open (vlc_object_t *obj)
 {
     demux_t *demux = (demux_t *)obj;
-    demux_sys_t *sys = vlc_obj_malloc(obj, sizeof (*sys));
+    if (demux->out == NULL)
+        return VLC_EGENERIC;
 
+    demux_sys_t *sys = vlc_obj_malloc(obj, sizeof (*sys));
     if (unlikely(sys == NULL))
         return VLC_ENOMEM;
 
diff --git a/modules/access/v4l2/demux.c b/modules/access/v4l2/demux.c
index e7637fb307..c30b16373f 100644
--- a/modules/access/v4l2/demux.c
+++ b/modules/access/v4l2/demux.c
@@ -73,6 +73,8 @@ static int InitVideo (demux_t *, int fd, uint32_t caps);
 int DemuxOpen( vlc_object_t *obj )
 {
     demux_t *demux = (demux_t *)obj;
+    if (demux->out == NULL)
+        return VLC_EGENERIC;
 
     demux_sys_t *sys = malloc (sizeof (*sys));
     if (unlikely(sys == NULL))
diff --git a/modules/access/v4l2/radio.c b/modules/access/v4l2/radio.c
index acd1337ae5..c91ee2a512 100644
--- a/modules/access/v4l2/radio.c
+++ b/modules/access/v4l2/radio.c
@@ -68,6 +68,8 @@ static int RadioControl (demux_t *demux, int query, va_list args)
 int RadioOpen (vlc_object_t *obj)
 {
     demux_t *demux = (demux_t *)obj;
+    if (demux->out == NULL)
+        return VLC_EGENERIC;
 
     /* Parse MRL */
     size_t pathlen = strcspn (demux->psz_location, ":;");
diff --git a/modules/access/vnc.c b/modules/access/vnc.c
index 97ae4a3d12..10c4c444df 100644
--- a/modules/access/vnc.c
+++ b/modules/access/vnc.c
@@ -386,6 +386,9 @@ static int Open( vlc_object_t *p_this )
     demux_t      *p_demux = (demux_t*)p_this;
     demux_sys_t  *p_sys;
 
+    if (p_demux->out == NULL)
+        return VLC_EGENERIC;
+
     p_sys = vlc_obj_calloc( p_this, 1, sizeof(demux_sys_t) );
     if( !p_sys ) return VLC_ENOMEM;
 
diff --git a/modules/access/wasapi.c b/modules/access/wasapi.c
index bc320d9943..9ecd4ccde0 100644
--- a/modules/access/wasapi.c
+++ b/modules/access/wasapi.c
@@ -384,6 +384,9 @@ static int Open(vlc_object_t *obj)
     demux_t *demux = (demux_t *)obj;
     HRESULT hr;
 
+    if (demux->out == NULL)
+        return VLC_EGENERIC;
+
     if (demux->psz_location != NULL && *demux->psz_location != '\0')
         return VLC_EGENERIC; /* TODO non-default device */
 



More information about the vlc-commits mailing list