[vlc-devel] [PATCH 4/5] se/archive: protect paths relying on p_sys->p_entry != NULL

Filip Roséen filip at atch.se
Fri Mar 17 03:22:14 CET 2017


The following paths will stumble into undefined-behavior land if
p_sys->p_entry is NULL.
---
 modules/stream_extractor/archive.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/modules/stream_extractor/archive.c b/modules/stream_extractor/archive.c
index b49a88f6c7..91f7deb68f 100644
--- a/modules/stream_extractor/archive.c
+++ b/modules/stream_extractor/archive.c
@@ -484,6 +484,9 @@ static int Control( stream_extractor_t* p_extractor, int i_query, va_list args )
             break;
 
         case STREAM_GET_SIZE:
+            if( p_sys->p_entry == NULL )
+                return VLC_EGENERIC;
+
             *va_arg( args, uint64_t* ) = archive_entry_size( p_sys->p_entry );
             break;
 
@@ -543,7 +546,7 @@ static ssize_t Read( stream_extractor_t *p_extractor, void* p_data, size_t i_siz
     libarchive_t* p_arc = p_sys->p_archive;
     ssize_t       i_ret;
 
-    if( p_sys->b_dead )
+    if( p_sys->b_dead || p_sys->p_entry == NULL )
         return 0;
 
     i_ret = archive_read_data( p_arc,
-- 
2.12.0


More information about the vlc-devel mailing list