[vlc-commits] avcodec: use av_get_pix_fmt_name(), fix potential out-of-band read

Rémi Denis-Courmont git at videolan.org
Fri Oct 12 10:39:53 CEST 2012


vlc/vlc-2.0 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Oct 10 18:17:03 2012 +0300| [689e95e5c1a3e129da6f3e6a040efd22ebd13dc7] | committer: Rémi Denis-Courmont

avcodec: use av_get_pix_fmt_name(), fix potential out-of-band read

Our custom codec names table lacked boundary checks and was incomplete.
(cherry picked from commit 88846171954a218ca9c401b87b0a4faffb5fc385)

Conflicts:
	modules/codec/avcodec/video.c

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=689e95e5c1a3e129da6f3e6a040efd22ebd13dc7
---

 modules/codec/avcodec/video.c |   16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index d03c7ad..3fccbbf 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -63,6 +63,7 @@
 #include "va.h"
 #if defined(HAVE_AVCODEC_VAAPI) || defined(HAVE_AVCODEC_DXVA2)
 #   define HAVE_AVCODEC_VA
+#   include <libavutil/pixdesc.h>
 #endif
 
 /*****************************************************************************
@@ -1160,18 +1161,9 @@ static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *p_context,
     /* Try too look for a supported hw acceleration */
     for( int i = 0; pi_fmt[i] != PIX_FMT_NONE; i++ )
     {
-        static const char *ppsz_name[PIX_FMT_NB] = {
-            [PIX_FMT_VDPAU_H264] = "PIX_FMT_VDPAU_H264",
-            [PIX_FMT_VAAPI_IDCT] = "PIX_FMT_VAAPI_IDCT",
-            [PIX_FMT_VAAPI_VLD] = "PIX_FMT_VAAPI_VLD",
-            [PIX_FMT_VAAPI_MOCO] = "PIX_FMT_VAAPI_MOCO",
-#ifdef HAVE_AVCODEC_DXVA2
-            [PIX_FMT_DXVA2_VLD] = "PIX_FMT_DXVA2_VLD",
-#endif
-            [PIX_FMT_YUYV422] = "PIX_FMT_YUYV422",
-            [PIX_FMT_YUV420P] = "PIX_FMT_YUV420P",
-        };
-        msg_Dbg( p_dec, "Available decoder output format %d (%s)", pi_fmt[i], ppsz_name[pi_fmt[i]] ?: "Unknown" );
+        const char *name = av_get_pix_fmt_name(pi_fmt[i]);
+        msg_Dbg( p_dec, "Available decoder output format %d (%s)", pi_fmt[i],
+                 name ? name : "unknown" );
 
         /* Only VLD supported */
         if( pi_fmt[i] == PIX_FMT_VAAPI_VLD )



More information about the vlc-commits mailing list