[vlc-devel] [PATCH] vlc 2.1.0 access_output/livehttp.c uninitialized data fix

LANGLOIS Olivier PIS -EXT olivier.pis.langlois at transport.alstom.com
Wed Oct 2 01:11:41 CEST 2013


because not all sout_access_out_sys_t data members are initialized, f_seglen ended up being garbage and resulted to a very long duration for the first segment in the m3u8 index file:

#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:NO
#EXT-X-MEDIA-SEQUENCE:1
#EXTINF:308800210012931175733052571648.00,
http://cwsla1gctd/hls/mystream-00000001.ts
#EXTINF:13.25,
http://cwsla1gctd/hls/mystream-00000002.ts
#EXTINF:14.03,
http://cwsla1gctd/hls/mystream-00000003.ts
#EXT-X-ENDLIST

This in turn made the old segment deletion impossible because

duration >= (first->f_seglength + (float)p_sys->i_seglen)

in isFirstItemRemovable was always false.

Signed-off-by: Olivier Langlois olivier at trillion01.com

--- vlc-2.1.0/modules/access_output/livehttp.c.orig     2013-10-01 18:43:35.058487310 -0400
+++ vlc-2.1.0/modules/access_output/livehttp.c  2013-10-01 18:51:11.393391604 -0400
@@ -218,7 +218,7 @@ static int Open( vlc_object_t *p_this )
         return VLC_EGENERIC;
     }

-    if( unlikely( !( p_sys = malloc ( sizeof( *p_sys ) ) ) ) )
+    if( unlikely( !( p_sys = calloc ( 1, sizeof( *p_sys ) ) ) ) )
         return VLC_ENOMEM;

     p_sys->i_seglen = var_GetInteger( p_access, SOUT_CFG_PREFIX "seglen" );
@@ -844,12 +844,10 @@ static ssize_t openNextFile( sout_access
     uint32_t i_newseg = p_sys->i_segment + 1;

     /* Create segment and fill it info that we can (everything excluding duration */
-    output_segment_t *segment = (output_segment_t*)malloc(sizeof(output_segment_t));
+    output_segment_t *segment = (output_segment_t*)calloc(1, sizeof(output_segment_t));
     if( unlikely( !segment ) )
         return -1;

-    memset( segment, 0 , sizeof( output_segment_t ) );
-
     segment->i_segment_number = i_newseg;
     segment->psz_filename = formatSegmentPath( p_access->psz_path, i_newseg, true );
     char *psz_idxFormat = p_sys->psz_indexUrl ? p_sys->psz_indexUrl : p_access->psz_path;



________________________________
CONFIDENTIALITY : This e-mail and any attachments are confidential and may be privileged. If you are not a named recipient, please notify the sender immediately and do not disclose the contents to another person, use it for any purpose or store or copy the information in any medium.



More information about the vlc-devel mailing list