[FFmpeg-cvslog] mxfdec: Fix CID 732262

Tomas Härdin git at videolan.org
Wed Oct 24 17:45:06 CEST 2012


ffmpeg | branch: master | Tomas Härdin <tomas.hardin at codemill.se> | Wed Oct 24 16:50:26 2012 +0200| [187630b2449f1eae1096f81f31bab7d81bed3cf1] | committer: Michael Niedermayer

mxfdec: Fix CID 732262

Coverity thinks ofs can end up 15, thus writing past the end of layout[]. This
is incorrect since it's always incremented by 2. Checking ofs <= 14 makes
Coverity happy and doesn't hurt.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=187630b2449f1eae1096f81f31bab7d81bed3cf1
---

 libavformat/mxfdec.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 1f583b8..3f6b7d9 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -782,14 +782,14 @@ static int mxf_read_index_table_segment(void *arg, AVIOContext *pb, int tag, int
 static void mxf_read_pixel_layout(AVIOContext *pb, MXFDescriptor *descriptor)
 {
     int code, value, ofs = 0;
-    char layout[16] = {0};
+    char layout[16] = {0}; /* not for printing, may end up not terminated on purpose */
 
     do {
         code = avio_r8(pb);
         value = avio_r8(pb);
         av_dlog(NULL, "pixel layout: code %#x\n", code);
 
-        if (ofs < 16) {
+        if (ofs <= 14) {
             layout[ofs++] = code;
             layout[ofs++] = value;
         }



More information about the ffmpeg-cvslog mailing list