utvideodec: Handle slice_height being zero
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 4 Mar 2015 17:36:14 +0000 (17:36 +0000)
committerLuca Barbato <lu_zero@gentoo.org>
Sun, 8 Mar 2015 23:51:15 +0000 (00:51 +0100)
Fixes out of array accesses.

CC: libav-stable@libav.org
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Bug-Id: CVE-2014-9604
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
libavcodec/utvideodec.c

index 7d75c59..bb8c7aa 100644 (file)
@@ -213,6 +213,8 @@ static void restore_median(uint8_t *src, int step, int stride,
         slice_start  = ((slice * height) / slices) & cmask;
         slice_height = ((((slice + 1) * height) / slices) & cmask) -
                        slice_start;
+        if (!slice_height)
+            continue;
 
         bsrc = src + slice_start * stride;
 
@@ -269,6 +271,8 @@ static void restore_median_il(uint8_t *src, int step, int stride,
         slice_height   = ((((slice + 1) * height) / slices) & cmask) -
                          slice_start;
         slice_height >>= 1;
+        if (!slice_height)
+            continue;
 
         bsrc = src + slice_start * stride;