[vlc-commits] demux/mp4: store length of payload in MP4_Box_data_string_t

Filip Roséen git at videolan.org
Wed Nov 16 15:22:57 CET 2016


vlc | branch: master | Filip Roséen <filip at atch.se> | Wed Nov 16 11:37:04 2016 +0100| [2750558c2d2566148f8844f607bc8eb40a834532] | committer: Francois Cartegnie

demux/mp4: store length of payload in MP4_Box_data_string_t

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.

Signed-off-by: Francois Cartegnie <fcvlcdev at free.fr>

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

 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;
 



More information about the vlc-commits mailing list