[vlc-commits] [Git][videolan/vlc][master] 2 commits: codec: omxil: check GetVlcChromaSizes return

Steve Lhomme (@robUx4) gitlab at videolan.org
Tue Aug 25 10:53:32 UTC 2026



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
520afe45 by François Cartegnie at 2026-08-25T09:09:27+00:00
codec: omxil: check GetVlcChromaSizes return

- - - - -
41db4208 by François Cartegnie at 2026-08-25T09:09:27+00:00
codec: omxil: check for overflow

fix #29720

- - - - -


3 changed files:

- modules/codec/omxil/mediacodec.c
- modules/codec/omxil/omxil.c
- modules/codec/omxil/utils.c


Changes:

=====================================
modules/codec/omxil/mediacodec.c
=====================================
@@ -1589,10 +1589,14 @@ static int Video_ProcessOutput(decoder_t *p_dec, mc_api_out *p_out,
             }
 
             unsigned int chroma_div;
-            GetVlcChromaSizes(p_dec->fmt_out.i_codec,
+            if( !GetVlcChromaSizes(p_dec->fmt_out.i_codec,
                               p_dec->fmt_out.video.i_width,
                               p_dec->fmt_out.video.i_height,
-                              NULL, NULL, &chroma_div);
+                              NULL, NULL, &chroma_div) )
+            {
+                picture_Release(p_pic);
+                return -1;
+            }
             CopyOmxPicture(p_sys->video.i_pixel_format, p_pic,
                            p_sys->video.i_slice_height, p_sys->video.i_stride,
                            (uint8_t *)p_out->buf.p_ptr, chroma_div);


=====================================
modules/codec/omxil/omxil.c
=====================================
@@ -137,11 +137,12 @@ static OMX_ERRORTYPE ImplementationSpecificWorkarounds(decoder_t *p_dec,
             def->format.video.eColorFormat = OMX_COLOR_FormatCbYCrY;
             p_fmt->i_codec =
                 p_fmt->video.i_chroma = GetVlcChromaFormat( def->format.video.eColorFormat );
-            GetVlcChromaSizes( p_fmt->i_codec,
+            if( !GetVlcChromaSizes( p_fmt->i_codec,
                                def->format.video.nFrameWidth,
                                def->format.video.nFrameHeight,
                                &p_port->i_frame_size, &p_port->i_frame_stride,
-                               &p_port->i_frame_stride_chroma_div );
+                               &p_port->i_frame_stride_chroma_div ))
+                return OMX_ErrorBadParameter;
             def->format.video.nStride = p_port->i_frame_stride;
             def->nBufferSize = p_port->i_frame_size;
         }
@@ -223,11 +224,15 @@ static OMX_ERRORTYPE SetPortDefinition(decoder_t *p_dec, OmxPort *p_port,
                     CHECK_ERROR(omx_error, "codec %4.4s doesn't match any OMX format",
                                 (char *)&p_fmt->i_codec );
                 }
-                GetVlcChromaSizes( p_fmt->i_codec,
+                if( !GetVlcChromaSizes( p_fmt->i_codec,
                                    def->format.video.nFrameWidth,
                                    def->format.video.nFrameHeight,
                                    &p_port->i_frame_size, &p_port->i_frame_stride,
-                                   &p_port->i_frame_stride_chroma_div );
+                                   &p_port->i_frame_stride_chroma_div ) )
+                {
+                    omx_error = OMX_ErrorBadParameter;
+                    goto error;
+                }
                 def->format.video.nStride = p_port->i_frame_stride;
                 def->nBufferSize = p_port->i_frame_size;
             }
@@ -241,11 +246,15 @@ static OMX_ERRORTYPE SetPortDefinition(decoder_t *p_dec, OmxPort *p_port,
                 CHECK_ERROR(omx_error, "OMX color format %i not supported",
                             (int)def->format.video.eColorFormat );
             }
-            GetVlcChromaSizes( p_fmt->i_codec,
+            if( !GetVlcChromaSizes( p_fmt->i_codec,
                                def->format.video.nFrameWidth,
                                def->format.video.nFrameHeight,
                                &p_port->i_frame_size, &p_port->i_frame_stride,
-                               &p_port->i_frame_stride_chroma_div );
+                               &p_port->i_frame_stride_chroma_div ) )
+            {
+                omx_error = OMX_ErrorBadParameter;
+                goto error;
+            }
             def->format.video.nStride = p_port->i_frame_stride;
             if (p_port->i_frame_size > def->nBufferSize)
                 def->nBufferSize = p_port->i_frame_size;
@@ -554,11 +563,15 @@ static OMX_ERRORTYPE GetPortDefinition(decoder_t *p_dec, OmxPort *p_port,
                 CHECK_ERROR(omx_error, "OMX color format %i not supported",
                             (int)def->format.video.eColorFormat );
             }
-            GetVlcChromaSizes( p_fmt->i_codec,
+            if( !GetVlcChromaSizes( p_fmt->i_codec,
                                def->format.video.nFrameWidth,
                                def->format.video.nFrameHeight,
                                &p_port->i_frame_size, &p_port->i_frame_stride,
-                               &p_port->i_frame_stride_chroma_div );
+                               &p_port->i_frame_stride_chroma_div ) )
+            {
+                omx_error = OMX_ErrorBadParameter;
+                goto error;
+            }
         }
         if(p_port->i_frame_size > def->nBufferSize)
             def->nBufferSize = p_port->i_frame_size;


=====================================
modules/codec/omxil/utils.c
=====================================
@@ -40,6 +40,8 @@
 #include "../../packetizer/hevc_nal.h"
 #include "../../packetizer/mpegvideo.h"
 
+#include <stdckdint.h>
+
 /*****************************************************************************
  * Events utility functions
  *****************************************************************************/
@@ -743,8 +745,17 @@ int GetVlcChromaSizes( vlc_fourcc_t i_fourcc,
     width = (width + 15) & ~0xF;
     height = (height + 15) & ~0xF;
 
-    if( size ) *size = width * height * chroma_format_table[i].i_size_mul / 2;
-    if( pitch ) *pitch = width * chroma_format_table[i].i_line_mul;
+    if( size )
+    {
+        if( ckd_mul( size, width, height ) ||
+            ckd_mul( size, *size, chroma_format_table[i].i_size_mul / 2 ) )
+            return 0;
+    }
+    if( pitch )
+    {
+        if( ckd_mul( pitch, width, chroma_format_table[i].i_line_mul ) )
+            return 0;
+    }
     if( chroma_pitch_div )
         *chroma_pitch_div = chroma_format_table[i].i_line_chroma_div;
     return !!chroma_format_table[i].i_codec;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/761f98ed4e6f037239deb1a7a7308221e760c55c...41db420818b2fd0a9e29449bbf2130ea33cbc404

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/761f98ed4e6f037239deb1a7a7308221e760c55c...41db420818b2fd0a9e29449bbf2130ea33cbc404
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list