[FFmpeg-cvslog] r31976 - trunk/libswscale/swscale.c

ramiro subversion
Wed Aug 18 21:37:37 CEST 2010


Author: ramiro
Date: Wed Aug 18 21:37:37 2010
New Revision: 31976

Log:
validate input data and linesizes

Modified:
   trunk/libswscale/swscale.c

Modified: trunk/libswscale/swscale.c
==============================================================================
--- trunk/libswscale/swscale.c	Wed Aug 18 21:28:22 2010	(r31975)
+++ trunk/libswscale/swscale.c	Wed Aug 18 21:37:37 2010	(r31976)
@@ -1827,6 +1827,21 @@ static void reset_ptr(const uint8_t* src
     }
 }
 
+static int check_image_pointers(uint8_t *data[4], enum PixelFormat pix_fmt,
+                                const int linesizes[4])
+{
+    const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
+    int i;
+
+    for (i = 0; i < 4; i++) {
+        int plane = desc->comp[i].plane;
+        if (!data[plane] || !linesizes[plane])
+            return 0;
+    }
+
+    return 1;
+}
+
 /**
  * swscale wrapper, so we don't need to export the SwsContext.
  * Assumes planar YUV to be in YUV order instead of YVU.
@@ -1842,6 +1857,15 @@ int sws_scale(SwsContext *c, const uint8
     if (srcSliceH == 0)
         return 0;
 
+    if (!check_image_pointers(src, c->srcFormat, srcStride)) {
+        av_log(c, AV_LOG_ERROR, "bad src image pointers\n");
+        return 0;
+    }
+    if (!check_image_pointers(dst, c->dstFormat, dstStride)) {
+        av_log(c, AV_LOG_ERROR, "bad dst image pointers\n");
+        return 0;
+    }
+
     if (c->sliceDir == 0 && srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) {
         av_log(c, AV_LOG_ERROR, "Slices start in the middle!\n");
         return 0;



More information about the ffmpeg-cvslog mailing list