[FFmpeg-cvslog] utvideodec: Prevent possible signed overflow

Ganesh Ajjanagadde git at videolan.org
Sat Oct 28 04:22:06 EEST 2017


ffmpeg | branch: master | Ganesh Ajjanagadde <gajjanag at gmail.com> | Mon Feb 22 23:21:58 2016 -0500| [1fe858136b315796dd5349f3b4448a29d1bd6fa1] | committer: Luca Barbato

utvideodec: Prevent possible signed overflow

Doing slice_end - slice_start is unsafe and can lead to undefined behavior
until slice_end has been properly sanitized.

Reviewed-by: Ronald S. Bultje <rsbultje at gmail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanag at gmail.com>
Signed-off-by: Luca Barbato <lu_zero at gentoo.org>

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

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

diff --git a/libavcodec/utvideodec.c b/libavcodec/utvideodec.c
index 808e3be067..2aaf861e62 100644
--- a/libavcodec/utvideodec.c
+++ b/libavcodec/utvideodec.c
@@ -361,12 +361,12 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
         slice_end   = 0;
         for (j = 0; j < c->slices; j++) {
             slice_end   = bytestream2_get_le32u(&gb);
-            slice_size  = slice_end - slice_start;
-            if (slice_end < 0 || slice_size < 0 ||
+            if (slice_end < 0 || slice_end < slice_start ||
                 bytestream2_get_bytes_left(&gb) < slice_end) {
                 av_log(avctx, AV_LOG_ERROR, "Incorrect slice size\n");
                 return AVERROR_INVALIDDATA;
             }
+            slice_size  = slice_end - slice_start;
             slice_start = slice_end;
             max_slice_size = FFMAX(max_slice_size, slice_size);
         }



More information about the ffmpeg-cvslog mailing list