aboutsummaryrefslogtreecommitdiffstats
path: root/libswscale
diff options
context:
space:
mode:
authorRamiro Polla <ramiro.polla@gmail.com>2010-08-18 19:37:37 +0000
committerRamiro Polla <ramiro.polla@gmail.com>2010-08-18 19:37:37 +0000
commita42c29febc501d5df3dd24b437cb884485862c56 (patch)
tree1df658a9a04190667125f740d9fe94eb35439805 /libswscale
parent18bbe9df9ae58c9452968364ab9863d7d7674a34 (diff)
downloadffmpeg-a42c29febc501d5df3dd24b437cb884485862c56.tar.gz
validate input data and linesizes
Originally committed as revision 31976 to svn://svn.mplayerhq.hu/mplayer/trunk/libswscale
Diffstat (limited to 'libswscale')
-rw-r--r--libswscale/swscale.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 3605836b14..d2e1146d67 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -1827,6 +1827,21 @@ static void reset_ptr(const uint8_t* src[], int format)
}
}
+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_t* const src[], const int srcStride[],
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;