[FFmpeg-cvslog] avcodec/loco: Check for end of input in pixel decode

Michael Niedermayer git at videolan.org
Mon Aug 5 20:50:43 EEST 2019


ffmpeg | branch: release/4.2 | Michael Niedermayer <michael at niedermayer.cc> | Fri Aug  2 22:14:22 2019 +0200| [11f01ad26c997ac3f6fd586a8a6dbf1def8e4311] | committer: Michael Niedermayer

avcodec/loco: Check for end of input in pixel decode

Fixes: Timeout (100sec -> 5sec)
Fixes: 15509/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LOCO_fuzzer-5724297261219840

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda at gmail.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 8305a4509af2908d88bb623deb816fdaa8056c83)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

 libavcodec/loco.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/loco.c b/libavcodec/loco.c
index e8c62b8178..5fb414b411 100644
--- a/libavcodec/loco.c
+++ b/libavcodec/loco.c
@@ -88,6 +88,8 @@ static inline int loco_get_rice(RICEContext *r)
         loco_update_rice_param(r, 0);
         return 0;
     }
+    if (get_bits_left(&r->gb) < 1)
+        return INT_MIN;
     v = get_ur_golomb_jpegls(&r->gb, loco_get_rice_param(r), INT_MAX, 0);
     loco_update_rice_param(r, (v + 1) >> 1);
     if (!v) {
@@ -163,6 +165,8 @@ static int loco_decode_plane(LOCOContext *l, uint8_t *data, int width, int heigh
         /* restore all other pixels */
         for (i = 1; i < width; i++) {
             val = loco_get_rice(&rc);
+            if (val == INT_MIN)
+                return -1;
             data[i] = loco_predict(&data[i], stride) + val;
         }
         data += stride;



More information about the ffmpeg-cvslog mailing list