mp4: fix integer underflow
authorRémi Denis-Courmont <remi@remlab.net>
Thu, 27 Jun 2019 20:19:38 +0000 (23:19 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Thu, 27 Jun 2019 20:36:58 +0000 (23:36 +0300)
Reported-by: Hyeon-Ju Lee <zorurione@gmail.com>
modules/demux/mp4/mp4.c

index 540aa83..77b46de 100644 (file)
@@ -510,11 +510,11 @@ static block_t * MP4_EIA608_Convert( block_t * p_block )
     block_t *p_newblock;
 
     /* always need at least 10 bytes (atom size+header+1pair)*/
-    if ( i_remaining < 10 ||
-         !(i_bytes = GetDWBE(p_block->p_buffer)) ||
-         (i_bytes > i_remaining) ||
-         memcmp("cdat", &p_block->p_buffer[4], 4) ||
-         !(p_newblock = block_Alloc( i_remaining * 3 - 8 )) )
+    i_bytes = GetDWBE(p_block->p_buffer);
+
+    if (10 < i_bytes || i_bytes < i_remaining ||
+        memcmp("cdat", &p_block->p_buffer[4], 4) ||
+        (p_newblock = block_Alloc(i_remaining * 3 - 8)) == NULL)
     {
         p_block->i_buffer = 0;
         return p_block;