[vlc-devel] [PATCH 1/4] demux/mp4: store length of payload in MP4_Box_data_string_t

Filip Roséen filip at atch.se
Wed Nov 16 11:37:04 CET 2016


MP4_ReadBox_String is invoked for boxes that contains raw
byte-content, though there is nothing saying that this raw-byte
sequence does not contain a null-byte ('\0').

If the sequence contains a null-byte, then there is no way (in the
previous implementation) for things working with the box-content to
access data that follows it (given that one cannot know if the
null-byte is the end-of-data terminator, or simply part of the
payload).

These changes make sure that the entire contents can be accessed by
including the length of the contents in MP4_Box_data_string_t.
---
 modules/demux/mp4/libmp4.c | 1 +
 modules/demux/mp4/libmp4.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index 1aff7bb..1f47713 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -3327,6 +3327,7 @@ static int MP4_ReadBox_String( stream_t *p_stream, MP4_Box_t *p_box )
     if( p_box->i_size < 8 || p_box->i_size > SIZE_MAX )
         MP4_READBOX_EXIT( 0 );
 
+    p_box->data.p_string->i_length = i_read;
     p_box->data.p_string->psz_text = malloc( p_box->i_size + 1 - 8 ); /* +\0, -name, -size */
     if( p_box->data.p_string->psz_text == NULL )
         MP4_READBOX_EXIT( 0 );
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index c72f85a..f165592 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -1176,6 +1176,7 @@ typedef struct
 typedef struct
 {
     char *psz_text;
+    uint64_t i_length;
 
 } MP4_Box_data_string_t;
 
-- 
2.10.2



More information about the vlc-devel mailing list